Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No current record problem

Status
Not open for further replies.

Glohamar

Programmer
Sep 3, 2003
248
US
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
 
Try use:
If rst.EOF and rst.BOF Then

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
That is the answer. Thanks. I never would have thought about using EOF and BOF.

Any ideas on using the Excel file to do the same so I do not have to import the spreadsheet to Access all the time?

Dave
 
You should be able to link the spreadsheet into Access and do the same thing.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top