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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a form that inputs data to a

Status
Not open for further replies.

RPW1

Technical User
Jun 14, 2001
19
0
0
US
I have a form that inputs data to a table. The form is "Form3" and it appends the records to table Cash receipts. In the on load event I use the following code and it works fine as long as there is data in cash receipts. However if the table is empty it cannot go to the next record. Is there a simple if statement that will just goto to the combo box if it is the first record in the table.

DoCmd.GoToRecord acDataForm, "Form3", acLast
DoCmd.GoToRecord acDataForm, "Form3", acNext
DoCmd.GoToControl "Combo29"

Thank you in advance for any help you may give.

Bob Woods
 
Try using DLookup to see if you have any records then act upon it. If you got records go to your control if not then skip it.

Personally, I would use a little DAO with .BOF and .EOF and based on the results then act upon it. I don't know how involved your db is?

Life's a journey enjoy the ride...

jazzz
 
Reading your scenario I see one problem.
If the table is empty and you open your form and execute the code this is what happens....

It hits the first line of code and tries to move to the last record (or "back" one record). Which it cannot do because there is no "last record". There are no records.
So you get an error message.

You could use an if statement to check to see if there are no records and then determine what to do in each case.

Blake




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top