Hi all,
This is probably related to my last question...
I had a database working with two keys, both numbers (Part Number and Serial Number), but I had to change Part Number to Text to allow for dashes
I was using the following code to find a specific record (it finds the last Serial Number I have in the database for a particular Part Number) but my code now does work when I have the Part Number as a Text (I get the error: Data type mismatch in criteria expression)
In my last question, the mod posted:Code:Private Sub Last_Record_Click()On Error GoTo Err_Last_Record_Click Dim criteria As String Dim lastSerial As Integer lastSerial = Me![Serial Number] criteria = "[Part Number]=" & Me![Part Number] & " AND [Serial Number]=" & lastSerial Do While (DCount("*", "Route Table", [critieria]) = 1) lastSerial = lastSerial + 1 criteria = "[Part Number]=" & Me![Part Number] & " AND [Serial Number]=" & lastSerial Loop lastSerial = lastSerial - 1 criteria = "[Part Number]=" & Me![Part Number] & " AND [Serial Number]=" & lastSerial Me.Form.Recordset.FindFirst [criteria] Me.[Operation Form].Form.Recordset.FindFirst [critieria] Me.SetFocus Exit_Last_Record_Click: Exit Sub Err_Last_Record_Click: MsgBox Err.Description Resume Exit_Last_Record_Click
Parameters for text field need apostrophe delimiters, date fields use #, numbers don't have delimiters.
So I am assuming the problem is because my Part Number is a Text and my Serial Number is a Number
I tried doing
criteria = "[Part Number] = ' " & Me![Part Number] & " ' " & " AND [Serial Number]=" & lastSerial
but that also doesn't work