Add code to display form based on query ??

G

Guest

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 instead of giving me the
datasheet view 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
 
G

Guest

Two ways
1. If the Query return the right resault, then create a form, using the
wizard that is based on this query.
And then change the command to

Private Sub cmdCreateReport_Click()
DoCmd.OpenForm "FormName"
End Sub
=============================
1. The usuall way will be, to base the report on the table, without the
filter in the query, and then pass the criteria to the form using the
WhereCondition

Private Sub cmdCreateReport_Click()

Dim MyWhereCond As string
MyWhereCond = "[FieldNameInTable] = " & Me.[FieldNameInForm]
Docmd.OpenForm "FormName",,,MyWhereCond

End Sub
 
G

Guest

OK I'll admit I'm treading in waters that are getting over my head, but I'll
do my best...

The original query is fed by a drop-down that is placed in the dialog box.
The idea is that each time a manager goes to the dialog box they would pull
down the list of all open incidents, choose one and click on the command
button to see the incident data fed into a form that would allow them to fill
out a follow-up report.

When I follow your first suggest and replace this code:

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

with this code:

Private Sub cmdCreateReport_Click()
DoCmd.OpenForm "frmUIRFollowUp"
End Sub

What I get in return is a frame in which the report should be but the frame
is completely white (no report, no text, etc.).

I'm totally stumped. All I'm really looking to do is have the original
command button do two things:
1. Generate data based on the drop down menu
2. Put that data into frmUIRFollowUp so my managers can complete a follow up.

The command button will do the first step but I still can't get it to do the
2nd.

Many thanks for your help,
David
 

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