B
bamphoenix
Need help to figure out how I can get this to work. I know it's probably
very simple and I've come close several times but it's just not good enough.
I have 2 Tables. One is Members and the other is Enrollments. Both have the
common field of MemberID. I have a form based off the Enrollments table and
need the MemberID to check if the data typed in is not part of the Members
table. If it is not then I would like a Msgbox to appear asking if I would
like to add this Member. If not, then clear. If the MemberID is already in
the Members table then the Member Information fields will auto-populate.
Also I would like the MemberID validating and clearing in the BeforeUpdate
event so that the RecordID will not autopopulate. I have tried to use the
NotInList event and it works great.....however.....the list can not requery
without giving errors.
I have tried this in BeforeUpdate but does not work unless the field is blank
or deleted:
If IsNull(MemberID) Then
MsgBox("Member can not be located. Add it?", vbQuestion + vbOKCancel) = vbOK
Then
DoCmd.OpenForm "Members", acNormal
DoCmd.GoToRecord , , acNewRec
Else
Me!MemberID.Undo
This is what I have for the autopopulate VBA in the AfterUpdate function that
works perfectly!!!:
Private Sub MemberID_AfterUpdate()
If IsNull(MemberID) Then
Exit Sub
End If
Dim dbGA_Medicare_Sales As Database
Dim rsMembers As Recordset
Set dbGA_Medicare_Sales = CurrentDb
Set rsMembers = dbGA_Medicare_Sales.OpenRecordset("Select * From Members
Where MemberID='" & MemberID & "'")
With rsMembers
If Not .EOF Then
FirstName = !FirstName
LastName = !LastName
SSN = !SSN
PhoneNumber = !PhoneNumber
ZipCode = !ZipCode
City = !City
State = !State
County = !County
End If
End With
rsMembers.Close
dbGA_Medicare_Sales.Close
End Sub
very simple and I've come close several times but it's just not good enough.
I have 2 Tables. One is Members and the other is Enrollments. Both have the
common field of MemberID. I have a form based off the Enrollments table and
need the MemberID to check if the data typed in is not part of the Members
table. If it is not then I would like a Msgbox to appear asking if I would
like to add this Member. If not, then clear. If the MemberID is already in
the Members table then the Member Information fields will auto-populate.
Also I would like the MemberID validating and clearing in the BeforeUpdate
event so that the RecordID will not autopopulate. I have tried to use the
NotInList event and it works great.....however.....the list can not requery
without giving errors.
I have tried this in BeforeUpdate but does not work unless the field is blank
or deleted:
If IsNull(MemberID) Then
MsgBox("Member can not be located. Add it?", vbQuestion + vbOKCancel) = vbOK
Then
DoCmd.OpenForm "Members", acNormal
DoCmd.GoToRecord , , acNewRec
Else
Me!MemberID.Undo
This is what I have for the autopopulate VBA in the AfterUpdate function that
works perfectly!!!:
Private Sub MemberID_AfterUpdate()
If IsNull(MemberID) Then
Exit Sub
End If
Dim dbGA_Medicare_Sales As Database
Dim rsMembers As Recordset
Set dbGA_Medicare_Sales = CurrentDb
Set rsMembers = dbGA_Medicare_Sales.OpenRecordset("Select * From Members
Where MemberID='" & MemberID & "'")
With rsMembers
If Not .EOF Then
FirstName = !FirstName
LastName = !LastName
SSN = !SSN
PhoneNumber = !PhoneNumber
ZipCode = !ZipCode
City = !City
State = !State
County = !County
End If
End With
rsMembers.Close
dbGA_Medicare_Sales.Close
End Sub