Next record based on button on form is wrong next record...please help
Next record based on button on form is wrong next record...please help
(OP)
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
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
RE: Next record based on button on form is wrong next record...please help
Kathryn
RE: Next record based on button on form is wrong next record...please help
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
RE: Next record based on button on form is wrong next record...please help
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.
Kathryn
RE: Next record based on button on form is wrong next record...please help
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