Open a different form with command button

N

Nancy

I have a command button on a form that opens a different form. I want to
open the same record on the command button form as on the main form. Now a
box pops up & asks for the record ID.

Please help.
 
K

Ken Snell \(MVP\)

The second form's RecordSource must be using a query that has a WHERE clause
based on the RecordID field? Get rid of that WHERE clause in that form's
RecordSource query.

Then, use code like this to open the second form -- I assume that your first
form has a control/field on it for RecordID, and I assume that it's a
numeric value, not a text value:

DoCmd.OpenForm "SecondFormName", , , "RecordID=" & Me.RecordID
 
N

Nancy

I am doing something wrong. There was a select criteria when running the
second form which is now gone.

On the command button to open the form, I removed the embedded macro and
added the code below. Note that the recordID is a number and is name
"Quote#".

Private Sub View_RFQ_Recap_button_Click()
DoCmd.OpenForm [frm_Quote_Form_Recap],,,"Quote_=" & Me.Quote_
End Sub

I've tried putting quotes around the second form name and using the # sign
instead of the underscore. Can you tell me what I am doing wrong.
Obviously, I am a novice.

Thanks for your help!
Nancy
 
K

Ken Snell \(MVP\)

Try this:

Private Sub View_RFQ_Recap_button_Click()
DoCmd.OpenForm "frm_Quote_Form_Recap",,,"[Quote#]=" & Me.Quote_
End Sub

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Nancy said:
I am doing something wrong. There was a select criteria when running the
second form which is now gone.

On the command button to open the form, I removed the embedded macro and
added the code below. Note that the recordID is a number and is name
"Quote#".

Private Sub View_RFQ_Recap_button_Click()
DoCmd.OpenForm [frm_Quote_Form_Recap],,,"Quote_=" & Me.Quote_
End Sub

I've tried putting quotes around the second form name and using the # sign
instead of the underscore. Can you tell me what I am doing wrong.
Obviously, I am a novice.

Thanks for your help!
Nancy


Ken Snell (MVP) said:
The second form's RecordSource must be using a query that has a WHERE
clause
based on the RecordID field? Get rid of that WHERE clause in that form's
RecordSource query.

Then, use code like this to open the second form -- I assume that your
first
form has a control/field on it for RecordID, and I assume that it's a
numeric value, not a text value:

DoCmd.OpenForm "SecondFormName", , , "RecordID=" & Me.RecordID

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
N

Nancy

Thank you! It worked perfectly.
--
Nancy


Ken Snell (MVP) said:
Try this:

Private Sub View_RFQ_Recap_button_Click()
DoCmd.OpenForm "frm_Quote_Form_Recap",,,"[Quote#]=" & Me.Quote_
End Sub

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Nancy said:
I am doing something wrong. There was a select criteria when running the
second form which is now gone.

On the command button to open the form, I removed the embedded macro and
added the code below. Note that the recordID is a number and is name
"Quote#".

Private Sub View_RFQ_Recap_button_Click()
DoCmd.OpenForm [frm_Quote_Form_Recap],,,"Quote_=" & Me.Quote_
End Sub

I've tried putting quotes around the second form name and using the # sign
instead of the underscore. Can you tell me what I am doing wrong.
Obviously, I am a novice.

Thanks for your help!
Nancy


Ken Snell (MVP) said:
The second form's RecordSource must be using a query that has a WHERE
clause
based on the RecordID field? Get rid of that WHERE clause in that form's
RecordSource query.

Then, use code like this to open the second form -- I assume that your
first
form has a control/field on it for RecordID, and I assume that it's a
numeric value, not a text value:

DoCmd.OpenForm "SecondFormName", , , "RecordID=" & Me.RecordID

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


I have a command button on a form that opens a different form. I want
to
open the same record on the command button form as on the main form.
Now
a
box pops up & asks for the record ID.

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top