I am trying to teach myself VBA for Access and am having some issues with the syntax for using text variables in a DLOOKUP function.
I am attempting to loop through a recordset one record at a time to see if two separate text fields from my recordset exist in the same two fields in a separate access table. If they do exist in the table, then I want to create an error message and display a message stating record exists already
Dim str1 As String
Set rst = db.OpenRecordset("temptbl")
Do Until rst.EOF
If Not IsNull(DLookup("Entry_Number" and "HTS_Line", "PO_Payment",
("Entry_Number= '" & rst!Entry_Number & "'") and ("HTS_Line= '" &
rst!HTS_Line & "'"))) Then
str1 = MsgBox("Entry number "" & rst!Entry_Number & "" already exists in
the PO_Payment table. Please investigate.", vbOKOnly)
Exit Do
rst.Close
DoCmd.DeleteObject acTable, "temptbl"
All fields are data type text but I am receiving a code 13 type mismatch error and cannot understand why. Can anyone help please?
Entry_Number
andHTS_Line
text columns?Entry_Number
sounds an awful lot like a number. – Erik A