Open specific record Access 2007 (1 Viewer)

David Eagar

Registered User.
Local time
Tomorrow, 07:57
Joined
Jul 2, 2007
Messages
924
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?
 

missinglinq

AWF VIP
Local time
Today, 17:57
Joined
Jun 20, 2003
Messages
6,420
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?
 

David Eagar

Registered User.
Local time
Tomorrow, 07:57
Joined
Jul 2, 2007
Messages
924
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)
 

ShaneMan

Registered User.
Local time
Today, 14:57
Joined
May 9, 2005
Messages
1,224
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:

boblarson

Smeghead
Local time
Today, 14:57
Joined
Jan 12, 2001
Messages
32,059
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
 

ShaneMan

Registered User.
Local time
Today, 14:57
Joined
May 9, 2005
Messages
1,224
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
 

David Eagar

Registered User.
Local time
Tomorrow, 07:57
Joined
Jul 2, 2007
Messages
924
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?
 

boblarson

Smeghead
Local time
Today, 14:57
Joined
Jan 12, 2001
Messages
32,059
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?
 

David Eagar

Registered User.
Local time
Tomorrow, 07:57
Joined
Jul 2, 2007
Messages
924
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

  • Wizard.zip
    35 KB · Views: 348
Last edited:

ChristopherM

Registered User.
Local time
Today, 22:57
Joined
Jan 5, 2000
Messages
38
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.
 

David Eagar

Registered User.
Local time
Tomorrow, 07:57
Joined
Jul 2, 2007
Messages
924
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

Top Bottom