Add code to command button to activate form ??

yeahyeahyeah

Registered User.
Local time
Today, 07:31
Joined
Jan 12, 2006
Messages
13
Per the instructions detailed here...
http://www.fontstuff.com/access/acctut08.htm

...I created a parameter query in the form of a drop down box that uses a
command button to produce a query.

The code is as follows:

Private Sub cmdCreateReport_Click()
DoCmd.OpenQuery "qryUIRFollowUp", acViewNormal, acEdit
DoCmd.Close acForm, "frmOpenUIRLookUp"

End Sub

This produces the data I need in datasheet view. I want to use this same
data to populate a form I've created that will use the above data as a
springboard to add more data to another table (also connected to my form).

So what code do I need to add to the above so that along with producing the
data the command jumps right to the next step and feeds this data
into the form and then displays that form?

Thanks for the help,
David
 
Hi David,

What is the name of your form that you want this query to open in?

And what version of Access do you have?

Robert88
 
Last edited:
Hi David,

I created a form frmStaffLocatorwithQuery in the Form tab, it contains the query, so this is your form that you were after?

I changed the OK button on the Staff Locator dialog box to changes in red with reference to yours but mine closes the form according to the notes........

Code:
Private Sub CmdOK_Click()

[COLOR="Red"]    DoCmd.OpenForm "frmStaffLocatorwithQuery", acNormal[/COLOR]
    DoCmd.Close acForm, "frmStaffLocator"

End Sub

Just check the zip.

Hope this is what you were after, or I hope this helps you.

Have a lovely weekend. :p

Robert88

P.S - It is a 2002 - 2003 Microsoft Access file.........
 

Attachments

Last edited:
Hi Robert,

Thanks so much for your help. However sorry it took me so long to reply; the database was at work so I couldn't try out your suggestion until this morning.

I adjusted the code with my form name and got the following:


Private Sub cmdCreateReport_Click()
DoCmd.OpenForm "frmUIRFollowUP", acNormal
DoCmd.Close acForm, "frmOpenUIRLookUp"

End Sub

Here's the problem (and I've never encountered this kind of thing before!): When I hit the OK button it returns a screen where the form should be however the only thing there is a completely blank (white) space inside the access frame. (When I hit the view button to switch to design view the form IS there however when I switch back to form view it's completely blank again.

Is this something with the data? I'm not sure if I have to adjust a control or not. Any help you could give on this would be greatly appreciated.

Many thanks,
David
 
Hi yeahyeahyeah,

Any chance of pasting a sample database of this? Could be a lot of things besides the code.

Robert88
 

Users who are viewing this thread

Back
Top Bottom