G
Guest
I have two tables in my Access database. One table is named Cases and the
other table is named Subpoena. My objective is to look up a CasFileID in the
Cases table and make sure it matches the field File_ID which is a field
located in the Subpoeana table. When the user types in their data in the
File_ID field which is located on my form, it will search the Cases table to
seek the value from the CasFileID. If the File_ID doesn't exist, it will
prompt the user for another one. I have figured out that part by using the
DLookUp function(I have displayed a copy of my code below).
Now, I have another field in the Cases table called CasCaption. What I would
like to accomplish is : when the user types in a File_ID on the form, I would
like the CasCaption to automatically populate in a field on my form called
Case. How can I accomplish this? Thanks you.
Private Sub File_ID_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[CasFileID]", "[Cases]", "[CasFileID] = """ &
Me.File_ID.Text & """")) Then
Cancel = False
Else
DoCmd.CancelEvent
MsgBox "File ID does not exist. Please add a different File ID."
End If
End Sub
other table is named Subpoena. My objective is to look up a CasFileID in the
Cases table and make sure it matches the field File_ID which is a field
located in the Subpoeana table. When the user types in their data in the
File_ID field which is located on my form, it will search the Cases table to
seek the value from the CasFileID. If the File_ID doesn't exist, it will
prompt the user for another one. I have figured out that part by using the
DLookUp function(I have displayed a copy of my code below).
Now, I have another field in the Cases table called CasCaption. What I would
like to accomplish is : when the user types in a File_ID on the form, I would
like the CasCaption to automatically populate in a field on my form called
Case. How can I accomplish this? Thanks you.
Private Sub File_ID_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("[CasFileID]", "[Cases]", "[CasFileID] = """ &
Me.File_ID.Text & """")) Then
Cancel = False
Else
DoCmd.CancelEvent
MsgBox "File ID does not exist. Please add a different File ID."
End If
End Sub