I am trying to figure this out. I know that I do not have a record, but I need the form to open with no error telling me I have no current record. The following is my code:
ECR = Right(ECNum, 5)
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT Field1, Field2 FROM PriorityModel WHERE Field2 LIKE '*" & ECR & "*'", dbOpenDynaset)
'If IsNull(rst!Field1) Then
If rst!Field1 = " " Then
PriNum = "0"
Else
PriNum = rst!Field1
End If
rst.Close
Set db = Nothing
As you can see I have been trying a couple of differnt options so that if there is no record for ECR, that the field on the form will display zero, otherwise it will diplay the number from Field1.
Also, the data for PriorityModel is in an Excel Spreadsheet. I moved it to a table for testing purposes, but I am wondering, can I link to the Excel file and run the same query and get the same results?
Thanks in advanced
Dave
ECR = Right(ECNum, 5)
Set db = CurrentDb()
Set rst = db.OpenRecordset("SELECT Field1, Field2 FROM PriorityModel WHERE Field2 LIKE '*" & ECR & "*'", dbOpenDynaset)
'If IsNull(rst!Field1) Then
If rst!Field1 = " " Then
PriNum = "0"
Else
PriNum = rst!Field1
End If
rst.Close
Set db = Nothing
As you can see I have been trying a couple of differnt options so that if there is no record for ECR, that the field on the form will display zero, otherwise it will diplay the number from Field1.
Also, the data for PriorityModel is in an Excel Spreadsheet. I moved it to a table for testing purposes, but I am wondering, can I link to the Excel file and run the same query and get the same results?
Thanks in advanced
Dave