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

DoCmd.GoToRecord question

Status
Not open for further replies.

BFP

Technical User
May 18, 2000
52
US
I have a button on a form which calls the DoCmd.GoToRecord and is supposed to grab the next record. Currently, Access is grabbing the "next record" according to the Customer Name field in my database, but this is not the desired behavior. I would like it to grab the next record according to a field called "ContactID", which is the way the objects are storred in my table.

Thus, the name of a field in the table and the name of the field in the form are both "ContactID" and the name of the Table/Form is "Contacts"

The current code is:
DoCmd.GoToRecord , , acNext

Funny thing is that this used to work before I got an error and had the DB repair itself.

Thanks,

--Dan
 
If you look at your table properties, do you have an "order by" filled in. If not put in ContactID. I assume you have the form based on the table. There are other ways to order the data but this should work.
 
Actually, I already have that property setup, but it still is not working properly.

--Dan
 
I think that you should set the focus on the field you need to be next, i.e. contactId.setfocus and then the docmd.goto record,,acnext

I hope this can help you.
 
Dan,

Drop this statement into a query ...

"SELECT * FROM [Contacts] ORDER BY [ContactID]"

.. then change the forms record source from the table that it currently uses to this query. :)

Also take a look at the 'ASC' and 'DESC' SQL keywords in the reference.
[sig]<p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top