using openargs for form list box query

  • Thread starter Thread starter shoulda
  • Start date Start date
S

shoulda

Guest
Hi

I'm trying to pass a value (surname) from a text box control in Form1 to Form2 using OpenArgs.

Form2 displays a list box with the row source being a query based on surname, which is first put into the variable Me.arg3 during Form2's Open_Form event.

List box query looks like this:

SELECT [Visitor's Details Query].visitorID, [Visitor's Details Query].nameLast, [Visitor's Details Query].Name, [Visitor's Details Query].dob, [Visitor's Details Query].company FROM [Visitor's Details Query] WHERE (([Visitor's Details Query].nameLast)=(Me.arg3));

The problem is I keep getting asked for a paramater value when opening Form2 from Form1.

I think the parameter is needed for the list box query because I did a test where I added an unbound text box to the form and set its value to Me.arg3. When I was asked for the paramater request, I typed in something different than the value passed from Form1, and the result showed Me.arg3 in the text box but the list box populated with results based on what I typed in the parameter request box.

How can I get the OpenArgs value to be put into a variable, then query based on that variable to populate the list box?

Help would be hugely appreciated.

Cheers.
 
can i give you an alternative method .

instead of using the open arg method , use a macro which set value from form 1 to form 2 then in your listbox row source , refer it to you textbox , that would be fairly simple enough to get it done.

supposingly your Textbox name is Text0 then

SELECT [Visitor's Details Query].visitorID, [Visitor's Details Query].nameLast, [Visitor's Details Query].Name, [Visitor's Details Query].dob, [Visitor's Details Query].company FROM [Visitor's Details Query] WHERE (([Visitor's Details Query].nameLast)=(Text0));
 
to use openargs on form1 you should put:

Code:
DoCmd.OpenForm "formname" , , , , acFormAdd , acDialog , textboxnameofsurname

then on the onLoad event of Form2 put the following:

Code:
if me.openargs <> "" then
me.textboxname = me.openargs
end if
 
maxmangion said:
then on the onLoad event of Form2 put the following:

On Open - the Load event will still ask for this parameter as the recordset(s) will have been loaded into the form and respective controls.
 
On Open - the Load event will still ask for this parameter as the recordset(s) will have been loaded into the form and respective controls.

Mine are on the OnLoad and they work fine ... i'm never prompted for any parameters. Do you think i still should put the code on the OnOpen ?
 

Users who are viewing this thread

Back
Top Bottom