Filter argument

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

Hi All,

I created two forms. In one of the forms, I created a
command button and when I click on the command button, the
other form will open. What I'm trying to do is,in the
first form, when I click on the command button, it takes
the parameter from the text box and pass the parameter to
the other form and the other form display the record base
on the parameter. The code below does that, but I'm
getting error.

Here is the code:
DoCmd.OpenForm "user", , , "[FieldName] = " &_
Me.ListBoxName.Value

Thanks for the help...

mike
 
Mike,
When you Open your second form, the "Me" in your code refers to the form
that is opening, not the one you came from...
(ex. names I'll used in my code... frmForm1 and lstUserName ... you
translate to your own names.)

DoCmd.OpenForm "user", , , "[UserName] = Forms!frmForm1!lstUserName"

That should do it...
 
Al Camp said:
Mike,
When you Open your second form, the "Me" in your code refers to the form
that is opening, not the one you came from...

Incorrect. "Me" is not affected by focus. It always refers to the object
where the code is running.
 
Thanks Al, But how do I pass the parameter from the first
form to the second form using your method. With the method
you gave me, it pops up with a screen asking me to type in
the user name. Is there any way that I can skip the pop up
screen and go directly to the record from the first form.

Thanks again,

Mike
-----Original Message-----
Mike,
When you Open your second form, the "Me" in your code refers to the form
that is opening, not the one you came from...
(ex. names I'll used in my code... frmForm1 and lstUserName ... you
translate to your own names.)

DoCmd.OpenForm "user", , , "[UserName] = Forms!frmForm1! lstUserName"

That should do it...
--
HTH...
Al Campagna
Candia Computer Consulting
Candia, NH

Hi All,

I created two forms. In one of the forms, I created a
command button and when I click on the command button, the
other form will open. What I'm trying to do is,in the
first form, when I click on the command button, it takes
the parameter from the text box and pass the parameter to
the other form and the other form display the record base
on the parameter. The code below does that, but I'm
getting error.

Here is the code:
DoCmd.OpenForm "user", , , "[FieldName] = " &_
Me.ListBoxName.Value

Thanks for the help...

mike


.
 
Thanks Al, But how do I pass the parameter from the first
form to the second form using your method. With the method
you gave me, it pops up with a screen asking me to type in
the user name. Is there any way that I can skip the pop up
screen and go directly to the record from the first form.

You need to embed quotes around the referenced value if it is a string:

DoCmd.OpenForm "user", , , "[FieldName] = """ & _
Me.ListBoxName.Value & """"
 
Rick,
Thanks for the clarification!
Al Camp

Rick Brandt said:
Incorrect. "Me" is not affected by focus. It always refers to the object
where the code is running.
 
Mike,
I made a mistake as to the concept of "ME" in your code. Rick Brandt
correctly picked up on that.

But I tested my response to you, and it worked.

**Please use your own form and field names when you try to use the example
code I sent... or try Bruce's approach (which is closer to your original
code)

Either method works. My method calls frmForm1 by it's "full" name, and
Bruce uses the ME to accomplish the same thing.
--
HTH...
Al Campagna
Candia Computer Consulting
Candia, NH




mike said:
Thanks Al, But how do I pass the parameter from the first
form to the second form using your method. With the method
you gave me, it pops up with a screen asking me to type in
the user name. Is there any way that I can skip the pop up
screen and go directly to the record from the first form.

Thanks again,

Mike
-----Original Message-----
Mike,
When you Open your second form, the "Me" in your code refers to the form
that is opening, not the one you came from...
(ex. names I'll used in my code... frmForm1 and lstUserName ... you
translate to your own names.)

DoCmd.OpenForm "user", , , "[UserName] = Forms!frmForm1! lstUserName"

That should do it...
--
HTH...
Al Campagna
Candia Computer Consulting
Candia, NH

Hi All,

I created two forms. In one of the forms, I created a
command button and when I click on the command button, the
other form will open. What I'm trying to do is,in the
first form, when I click on the command button, it takes
the parameter from the text box and pass the parameter to
the other form and the other form display the record base
on the parameter. The code below does that, but I'm
getting error.

Here is the code:
DoCmd.OpenForm "user", , , "[FieldName] = " &_
Me.ListBoxName.Value

Thanks for the help...

mike


.
 
Back
Top