A
azu_daioh
I'm getting this error message on one of the database but not on the
other. "You cannot add or change a record because a related record is
required in table <name>. (Error 3201)"
Both databases have similar relatioships/design so I dont know why
it's working on one and not the other.
here's the code:
Private Sub License__AfterUpdate()
Dim xLic As String
xLic = Nz(DLookup("[License#]", "Doctor Basic Info", _
"[License#] = '" & Me.[License#] & "'"), "0")
If xLic = "0" Then
MsgBox "Doctor's license# is currently not in the database." &
Chr(13) _
& "Please complete the 'Basic Doctor Info' before
proceeding.", _
vbCritical, "Doctor Record Not Found"
DoCmd.OpenForm "Doctor Table", acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Doctor Table]![License#] = Forms![Add New Monthly
Payment Record]![License#]
End If
End Sub
In the database where the code works I have this relationship
[Doctor Basic Info] 1-Many [Monthy Activity]
[Monthly Activity] is the record source for Forms![Add New Monthly
Payment Record]
[Doctor Basic Info] is the record source for Forms![Doctor Table]
In the database where the code does not work:
[tbl_ClaimDetails] 1-Many [tbl_Doctors]
And this is the code that doesnt work:
Private Sub drLicense_AfterUpdate()
Dim xLic As String
xLic = Nz(DLookup("[drLicense]", "tbl_Doctor", _
"[drLicense] = '" & Me.[drLicense] & "'"), "0")
If xLic = "0" Then
MsgBox "Doctor's license# is currently not in the database." &
Chr(13) _
& "Please complete the 'Basic Doctor Info' before
proceeding.", _
vbCritical, "Doctor Record Not Found"
DoCmd.OpenForm "frm_Doctor", acNormal
DoCmd.GoToRecord , , acNewRec
Forms![frm_Doctor]![drLicense] = Forms![frm_Doctors]![License#]
End If
End Sub
other. "You cannot add or change a record because a related record is
required in table <name>. (Error 3201)"
Both databases have similar relatioships/design so I dont know why
it's working on one and not the other.
here's the code:
Private Sub License__AfterUpdate()
Dim xLic As String
xLic = Nz(DLookup("[License#]", "Doctor Basic Info", _
"[License#] = '" & Me.[License#] & "'"), "0")
If xLic = "0" Then
MsgBox "Doctor's license# is currently not in the database." &
Chr(13) _
& "Please complete the 'Basic Doctor Info' before
proceeding.", _
vbCritical, "Doctor Record Not Found"
DoCmd.OpenForm "Doctor Table", acNormal
DoCmd.GoToRecord , , acNewRec
Forms![Doctor Table]![License#] = Forms![Add New Monthly
Payment Record]![License#]
End If
End Sub
In the database where the code works I have this relationship
[Doctor Basic Info] 1-Many [Monthy Activity]
[Monthly Activity] is the record source for Forms![Add New Monthly
Payment Record]
[Doctor Basic Info] is the record source for Forms![Doctor Table]
In the database where the code does not work:
[tbl_ClaimDetails] 1-Many [tbl_Doctors]
And this is the code that doesnt work:
Private Sub drLicense_AfterUpdate()
Dim xLic As String
xLic = Nz(DLookup("[drLicense]", "tbl_Doctor", _
"[drLicense] = '" & Me.[drLicense] & "'"), "0")
If xLic = "0" Then
MsgBox "Doctor's license# is currently not in the database." &
Chr(13) _
& "Please complete the 'Basic Doctor Info' before
proceeding.", _
vbCritical, "Doctor Record Not Found"
DoCmd.OpenForm "frm_Doctor", acNormal
DoCmd.GoToRecord , , acNewRec
Forms![frm_Doctor]![drLicense] = Forms![frm_Doctors]![License#]
End If
End Sub