Open specific record Access 2007

David Eagar

Registered User.
Local time
Today, 15:41
Joined
Jul 2, 2007
Messages
922
Just getting to grips with Access 2007. Have created a form with a serach criteria (works fine) and a command button to open a specified record on another form.

Wizard created Open form frmCD, Form, , "[id]=" & [id], , Normal

The correct form opens but it goes to the first record, not the record specified from the first form. This technique has always workd in 2000 & 2002

Is there some new procedure to make this work in 2007?
 
I assume you're "paraphrasing" as it were, since none of this

Open form frmCD, Form, , "[id]=" & [id], , Normal

is actual VBA syntax.

Is ID text or numeric datatype?
 
Open form frmCD, Form, , "[id]=" & [id], , Normal

This has come from the On Click event set up by the command button wizard

ID is the PK (record number) and the search produces a list based on search criteria - so id could be 1,5,9,23,57 etc

On a continuous form, each record showing has a command button that is supposed to open the frmCD (it does) and go to the matching ID record (it doesn't)
 
Open form frmCD, Form, , "[id]=" & [id], , Normal

This has come from the On Click event set up by the command button wizard

ID is the PK (record number) and the search produces a list based on search criteria - so id could be 1,5,9,23,57 etc

On a continuous form, each record showing has a command button that is supposed to open the frmCD (it does) and go to the matching ID record (it doesn't)

David, Missingling asked a question above your post that is important for you to answer. If your paraphrasing the code you've provided then that's telling him one thing, but if your not then your code is off by quite abit.
It should look something more like this:
DoCmd.OpenForm "frmCD",,,"[id]=" & Me.id This is assuming [id] is numeric. Also, notice there are 3 comma's after the form name and not two.

HTH,
Shane
 
Last edited:
If you did this (used the wizard to create a button) in Access 2007, you won't get code, you'll get an embedded macro. It looks like you are showing what the embedded macro has for arguments (and yes guys the arguments for the embedded macro look like that in that order).

I would, instead, select [Event Procedure] and then put in the VBA of

DoCmd.OpenForm "frmCD", acNormal, , "[id]=" & Me!id
 
If you did this (used the wizard to create a button) in Access 2007, you won't get code, you'll get an embedded macro. It looks like you are showing what the embedded macro has for arguments (and yes guys the arguments for the embedded macro look like that in that order).

I would, instead, select [Event Procedure] and then put in the VBA of

DoCmd.OpenForm "frmCD", acNormal, , "[id]=" & Me!id

Always learning. Did not know that.

Thanks for stepping in Bob.
Shane
 
If you did this (used the wizard to create a button) in Access 2007, you won't get code, you'll get an embedded macro. It looks like you are showing what the embedded macro has for arguments (and yes guys the arguments for the embedded macro look like that in that order).

I would, instead, select [Event Procedure] and then put in the VBA of

DoCmd.OpenForm "frmCD", acNormal, , "[id]=" & Me!id

As always, thanks for the advice. Is it a concern (bug) that the code that the wizard creates doesn't actually work?
 
As always, thanks for the advice. Is it a concern (bug) that the code that the wizard creates doesn't actually work?

Sorry, but i have a question for your question. How did the "[id]=" & [id] part get in there? I tried creating something similar and it would not put that into the macro automatically. I had to type it into the arguments. Can you tell me the exact steps that you used to create the button so that it had that in the arguments?
 
On my form, added command button and followed the wizard to open form at specific record linking id to id and selecting Open to specific record
 

Attachments

Last edited:
You're doing better than me with the Access 2007 command button wizard - when I tried to use it to open a form at a specific record it produced a list of controls in the form I was opening, but the box for the controls on the form I was adding the button to was empty so there nothing to select to create a match! I tried this several times even restarting Access but with the same result - in the end I gave up and used VBA instead.
 
Since my computer with Access 2007 and Vista got stolen, this is no longer an issue for me - i am back on XP / 2002
 

Users who are viewing this thread

Back
Top Bottom