B
Brenda
Curious to know if anyone could provide help for the below code.
I have a form called Members, a table called Members and a table called
Members_Banned. New members are entered through the Members form are stored
in the Members table and banned members are in Members_Banned table through
non use of a form. I had the Members form and Members table successfully
working with everything inbetween the ** notations below (these are not part
of the code but used here just to direct attention) omitted. I had a need to
separate to another table for banned members and I added this code to search
across two tables and display information into the members form when a record
is found. Omit the code and all works well as it should. If there is a
duplicate record the code will erase the new record entry attempt and display
the existing record once message of duplicate record found message is
acknowledged. If there is no duplicate record the new member data is stored
in the Members table.
When I run the code with the newly added code between the ** below I get to
the point to where the code finds the records in the Members table and
displays information as it should but when it searches but whe the record is
in the Members_Banned table it gives me just the message saying a record
exists and clears the entry but does not show me the record. I can only
assume this is because the form is tied to the Members table as a data source.
I feel there is a simple bit of code I am missing that would allow this.
Using the form I need all information ( new ) to dump into the Members table
and nothing into the Members_Banned table. That table is solely for keeping
information from the past and is not updatable through the use of a form. I
just need the code to go there and display the information that is in the
table into the Members form.
Thanks in advance!
Brenda
Private Sub State_ID_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.State_ID.Value
stLinkCriteria = "[State_ID]=" & "'" & SID & "'"
'Check Members table for duplicate State ID number
If DCount("State_ID", "Members", _
stLinkCriteria) > 0 Then
'Undo duplicate entry attempt
Me.Undo
'Message box warning of duplication
MsgBox "Membership history exists in the database for State ID " &
SID & "!" _
& vbCr & vbCr & "You will now been taken to the record for
detailed information!", _
vbInformation, "Membership History Found!"
'Go to record of original State ID Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
** 'Check Banned Members table for duplicate State ID number
ElseIf DCount("State_ID", "Members_Banned", _
stLinkCriteria) > 0 Then
'Undo duplicate entry attempt
Me.Undo
'Message box warning of duplication
MsgBox "Membership history exists in the database for State ID " &
SID & "!" _
& vbCr & vbCr & "You will now been taken to the record for
detailed information!", _
vbInformation, "Membership History Found!"
'Go to record of original State ID Number
rsc.FindFirst stLinkCriteria
** Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
I have a form called Members, a table called Members and a table called
Members_Banned. New members are entered through the Members form are stored
in the Members table and banned members are in Members_Banned table through
non use of a form. I had the Members form and Members table successfully
working with everything inbetween the ** notations below (these are not part
of the code but used here just to direct attention) omitted. I had a need to
separate to another table for banned members and I added this code to search
across two tables and display information into the members form when a record
is found. Omit the code and all works well as it should. If there is a
duplicate record the code will erase the new record entry attempt and display
the existing record once message of duplicate record found message is
acknowledged. If there is no duplicate record the new member data is stored
in the Members table.
When I run the code with the newly added code between the ** below I get to
the point to where the code finds the records in the Members table and
displays information as it should but when it searches but whe the record is
in the Members_Banned table it gives me just the message saying a record
exists and clears the entry but does not show me the record. I can only
assume this is because the form is tied to the Members table as a data source.
I feel there is a simple bit of code I am missing that would allow this.
Using the form I need all information ( new ) to dump into the Members table
and nothing into the Members_Banned table. That table is solely for keeping
information from the past and is not updatable through the use of a form. I
just need the code to go there and display the information that is in the
table into the Members form.
Thanks in advance!
Brenda
Private Sub State_ID_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SID = Me.State_ID.Value
stLinkCriteria = "[State_ID]=" & "'" & SID & "'"
'Check Members table for duplicate State ID number
If DCount("State_ID", "Members", _
stLinkCriteria) > 0 Then
'Undo duplicate entry attempt
Me.Undo
'Message box warning of duplication
MsgBox "Membership history exists in the database for State ID " &
SID & "!" _
& vbCr & vbCr & "You will now been taken to the record for
detailed information!", _
vbInformation, "Membership History Found!"
'Go to record of original State ID Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
** 'Check Banned Members table for duplicate State ID number
ElseIf DCount("State_ID", "Members_Banned", _
stLinkCriteria) > 0 Then
'Undo duplicate entry attempt
Me.Undo
'Message box warning of duplication
MsgBox "Membership history exists in the database for State ID " &
SID & "!" _
& vbCr & vbCr & "You will now been taken to the record for
detailed information!", _
vbInformation, "Membership History Found!"
'Go to record of original State ID Number
rsc.FindFirst stLinkCriteria
** Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub