View Full Version : This is easy, but I'm stumped!


nelslynn
12-16-2001, 06:37 AM
I have form2 that I am opening from a mainform. What goes on form2 depends on a query (based on a combobox). I want to open this form with this query.

Right now I have a Public Sub to open Form2. I am sending it the query as the critera for opening the Form2. And that is where I am. I tried: Docmd.openform "frm", acNormal,,qry,acFromEdit ---> no go

jwindon
12-16-2001, 07:09 AM
Base your form2 off of the query. Have the button that currently runs off to the public function, open form2. The query that the form is based off of will run before the form opens.

Do you have the combo box set as the criteria in the query?

nelslynn
12-16-2001, 07:19 AM
"The query that the form is based off of will run before the form opens." ---> Thats my question, how do I set the forms query 'on the fly' (in VBA). It can be based on one of four queries (based on 3 choices made on the mainform).
I guess I can use the Filter feature of the "Docmd.openform", but I thought I could just set the form's recordset (query) another way. Is there another way?

jwindon
12-16-2001, 07:27 AM
Query Def may be what you're after. I'm just wondering what criteria are in the four queries you are using. I am assuming that their criteria (all four) is based off of the form. It IS possible that this criteria could be evaluated by one query versus four. What does the combo box form and the four queries look for?

Here is a good example for querying a forms recordset. You would have to add the If-Then part into the query to set an Add Mode.
http://www.access-programmers.co.uk/ubb/Forum4/HTML/004007.html



[This message has been edited by jwindon (edited 12-16-2001).]