D
Denise Pollock
I have a from that takes 2 fields on the form combines them together with a
dash inbetween them and creates the primary key in the table. I am trying to
create a code that will check to see if that combination already exists in
the database before running the SQL code to insert all the data into the
table. I stole a code from another post but it does not seem to work for me,
I assume because I am trying to combine two fields. When I run the code I
get the msgbox that the Weld_ID already exists everytime.
Here is the code I currently have
Dim strSQL As String
If IsNull(DLookup("[Weld_ID]", "[Welds]", "[WELD_ID]= '" & assy_mark_fk &
"-" & weld_num_fk & _
"'")) Then
'Weld_ID does exist
MsgBox "Weld already exists."
Else
'Weld_ID doesn't exist
strSQL = "blah blah big long sql query goes here, this part already works"
DoCmd.RunSQL strSQL
MsgBox "WeldID " & assy_mark_fk & "-" & weld_num_fk & " Created"
End If
Would appreciate it if someone could fix this for me.
Thanks,
dash inbetween them and creates the primary key in the table. I am trying to
create a code that will check to see if that combination already exists in
the database before running the SQL code to insert all the data into the
table. I stole a code from another post but it does not seem to work for me,
I assume because I am trying to combine two fields. When I run the code I
get the msgbox that the Weld_ID already exists everytime.
Here is the code I currently have
Dim strSQL As String
If IsNull(DLookup("[Weld_ID]", "[Welds]", "[WELD_ID]= '" & assy_mark_fk &
"-" & weld_num_fk & _
"'")) Then
'Weld_ID does exist
MsgBox "Weld already exists."
Else
'Weld_ID doesn't exist
strSQL = "blah blah big long sql query goes here, this part already works"
DoCmd.RunSQL strSQL
MsgBox "WeldID " & assy_mark_fk & "-" & weld_num_fk & " Created"
End If
Would appreciate it if someone could fix this for me.
Thanks,