Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Open a different form with command button

Geek News

Open a different form with command button
Nancy 11/15/2008 3:03:01 PM
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.
--
Nancy
Re: Open a different form with command button
"Ken Snell \(MVP\)" <kthsneisllis9[ at ]ncoomcastt.renaetl> 11/15/2008 3:25:53 PM
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/


"Nancy" <Nancy[ at ]strem.com> wrote in message
news:59BA2491-2BC7-4FE3-9A52-C671F3168E61[ at ]microsoft.com...
[Quoted Text]
>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.
> --
> Nancy


Re: Open a different form with command button
Nancy 11/15/2008 8:07:01 PM
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)" wrote:

[Quoted Text]
> 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/
>
>
> "Nancy" <Nancy[ at ]strem.com> wrote in message
> news:59BA2491-2BC7-4FE3-9A52-C671F3168E61[ at ]microsoft.com...
> >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.
> > --
> > Nancy
>
>
>
Re: Open a different form with command button
"Ken Snell \(MVP\)" <kthsneisllis9[ at ]ncoomcastt.renaetl> 11/15/2008 10:04:30 PM
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" <Nancy[ at ]strem.com> wrote in message
news:2F57DB4F-85A7-48E3-9E2F-8B9B5C147E02[ at ]microsoft.com...
[Quoted Text]
>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)" wrote:
>
>> 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/
>>
>>
>> "Nancy" <Nancy[ at ]strem.com> wrote in message
>> news:59BA2491-2BC7-4FE3-9A52-C671F3168E61[ at ]microsoft.com...
>> >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.
>> > --
>> > Nancy
>>
>>
>>


Re: Open a different form with command button
Nancy 11/16/2008 1:01:02 AM
Thank you! It worked perfectly.
--
Nancy


"Ken Snell (MVP)" wrote:

[Quoted Text]
> 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" <Nancy[ at ]strem.com> wrote in message
> news:2F57DB4F-85A7-48E3-9E2F-8B9B5C147E02[ at ]microsoft.com...
> >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)" wrote:
> >
> >> 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/
> >>
> >>
> >> "Nancy" <Nancy[ at ]strem.com> wrote in message
> >> news:59BA2491-2BC7-4FE3-9A52-C671F3168E61[ at ]microsoft.com...
> >> >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.
> >> > --
> >> > Nancy
> >>
> >>
> >>
>
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net