By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,799 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,799 IT Pros & Developers. It's quick & easy.

Ho to goto to a specific record using the Docomd.GoToRecord

P: 7
Hi all I need some help.

I'm working on a project where i need to move on some records depending the value that the user chooses from a list box.I use the DoCmd.GoToRecord Like this:

"DoCmd.GoToRecord acDataForm, "ADV_FORM", acGoTo, LIST.Value"

Where LIST.Value is the primery key of a table and that's Auto Number.
The problem is that if the key has the value 8,the current record will be the 8th and not the record that has 8 as key (The numbering has gaps 1-2-4-7-8...etc)

What i want is to move to the current record to the one that has the specified key.The help file talks about expression as a fourth argument of the DoCmd so I tried:

"DoCmd.GoToRecord acDataForm, "ADV_FORM", acGoTo, [ADV]![code]=8"

But didn't worked.Is there a way to do that whith DoCmd.GoToRecord,or should I try SQL?(I will be needing help with this too..)

Thanks for any help
May 29 '07 #1
Share this Question
Share on Google+
3 Replies

puppydogbuddy
Expert 100+
P: 1,923
Hi all I need some help.

I'm working on a project where i need to move on some records depending the value that the user chooses from a list box.I use the DoCmd.GoToRecord Like this:

"DoCmd.GoToRecord acDataForm, "ADV_FORM", acGoTo, LIST.Value"

Where LIST.Value is the primery key of a table and that's Auto Number.
The problem is that if the key has the value 8,the current record will be the 8th and not the record that has 8 as key (The numbering has gaps 1-2-4-7-8...etc)

What i want is to move to the current record to the one that has the specified key.The help file talks about expression as a fourth argument of the DoCmd so I tried:

"DoCmd.GoToRecord acDataForm, "ADV_FORM", acGoTo, [ADV]![code]=8"

But didn't worked.Is there a way to do that whith DoCmd.GoToRecord,or should I try SQL?(I will be needing help with this too..)

Thanks for any help
Try using the DoCmd.FindRecord, which allows you to use the keyvalue as the search key.

see this link for an explanation and example syntax:

http://www.blueclaw-db.com/docmd_findrecord_example.htm
May 30 '07 #2

P: 7
I've tried the DoCmd.FindRecord but nothing huppents.Actually what i get from the debuging is that DoCmd.FindRecord don't make the record which i want as the current record.Am i doing something rong?

DoCmd.FindRecord makes the record that looks for current or not?The help file isn't helpfull at all...
May 30 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
I've tried the DoCmd.FindRecord but nothing huppents.Actually what i get from the debuging is that DoCmd.FindRecord don't make the record which i want as the current record.Am i doing something rong?

DoCmd.FindRecord makes the record that looks for current or not?The help file isn't helpfull at all...
The default findRecord command will return the record you want if there is a match to the field that currently has focus, Consequently, you need to set focus on the field that you want to search before you execute the FindFirst as shown below:
Expand|Select|Wrap|Line Numbers
  1. Me.List.SetFocus                   '  set focus on the field to be searched
  2. DoCmd.FindRecord List.value , , False , , True , , False 
  3.  
May 30 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.