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!

Next record based on button on form is wrong next record...please help

Status
Not open for further replies.

BFP

Technical User
May 18, 2000
52
0
0
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. BTW, someone had suggested in a different forum that I set the table preferences to sort by ContactID and this is already the case and doesn't work.

Thanks,

--Dan
 
I'm not sure what you mean by "set the table preferences to sort by ContactID"? Do you have the underlying RecordSource for the form sorted by Contact ID?
 
Hello Kathryn.

Yes I do have the underlying RecordSource for the form sorted by ContactID. This is why I can't figure out what is wrong?

--Dan
 
Dan,

I am clueless, but I would try the following:

1. Look at the table design of the table with CustomerName and ContactID. See if there are any indexes on CustomerName?

2. Is the underlying RecordSource a table or a query? If it is a table, then create a query that sorts on ContactID. Table sorting doesn't always make it to forms.

Let me know how it goes.
 
OK, I've found a solution, but am puzzled by why it worked. Basically, I ran the "Compact and Repair Database" and things were working. I exited and re-entered the database and it went back to normal, but I did notice that the form was no longer set to Orderby ContactID, so I set this AGAIN and it seems to be functioning properly.

I think the moral of the story is: if you are sure that something should be working differently than it is, try the "Compact and Repair" option and then after you run that, go back and ensure that the settings revolving around the problme are set properly. Of course, we can be sure and thank Microsoft for once again providing us with buggy products that exhibit pseudo-random behavior.

Thanks for trying to help though.

--Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top