work4livinsean
Programmer
Hi Everyone,
I have a pretty extensive database but I need to do something very simple. I have created a form that has a submit button. When the submit button is clicked it takes all the fields (in the form) and puts them into a table (#1). I want to take one of those fields (lets say the name field) and compare it to a name field on another table (#2). If the name is found display a msgbox "Already found" and if not found do the process of adding the field to the table (#1). I cannot figure this out! Here is my code:
Dim findItPlease As String
findItPlease = Me.ApexID.Value '**Value from form
Dim didItFind As Variant '**Should it be variant?
didItFind = DLookup("[Name]", "tblActiveISD", "[APEX_ID] = " & findItPlease)
'**Name and APEX_ID are fields in table (#2)
If didItFind Is Nothing Then
MsgBox "Could not find, which is what I want"
'I have a SQL statement that adds the data successfully
Else
MsgBox "Found, do nothing"
End If
I have a pretty extensive database but I need to do something very simple. I have created a form that has a submit button. When the submit button is clicked it takes all the fields (in the form) and puts them into a table (#1). I want to take one of those fields (lets say the name field) and compare it to a name field on another table (#2). If the name is found display a msgbox "Already found" and if not found do the process of adding the field to the table (#1). I cannot figure this out! Here is my code:
Dim findItPlease As String
findItPlease = Me.ApexID.Value '**Value from form
Dim didItFind As Variant '**Should it be variant?
didItFind = DLookup("[Name]", "tblActiveISD", "[APEX_ID] = " & findItPlease)
'**Name and APEX_ID are fields in table (#2)
If didItFind Is Nothing Then
MsgBox "Could not find, which is what I want"
'I have a SQL statement that adds the data successfully
Else
MsgBox "Found, do nothing"
End If