Rick Stanich
King and Supreme Ruler
- Local time
- Today, 11:33
- Joined
- May 13, 2009
- Messages
- 93
I am having trouble with syntax for a DLookup.
The foriegn key "fkJobID" is in tblJobParts, I look in tblJobs for Me.tbJobNo, how do I complete the DLookup when the foreign key is in another table?
See attached image for Relationships.
Code:
Private Sub tbJobNo_BeforeUpdate(Cancel As Integer)
'Get the Pk value of the Job number in tblJobs
lngID = DLookup("pkJobID", "tblJobs", "txtJobNo='" _
& Me.tbJobNo & "'")
'Now check if the revision value entered exists for that _
Job numbers PK value in tblJobs
If IsNull(DLookup("txtJobNo", "tblJobs", "txtJobNo='" _
& Me.tbJobNo & "' And fkJobID=" & lngID)) Then
'above: [COLOR=red]fkJobID not exist in tblJobs[/COLOR]
'No match was found
Cancel = True
MsgBox "The revision value entered does not exist for this part number."
Else
SaveSetting AppName:="GeoMeasure", section:="CMM Data", _
Key:="tbJobNo", setting:=tbJobNo
End If
End Sub
See attached image for Relationships.