×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

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?

Kathryn


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

(OP)
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

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

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.

Kathryn


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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close