OpenForm Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I am getting the following error:

"method or data member not found"

when I run a sub containing this line:

DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service" =
Me.TextBox.PartnerName

The debugger highlights the last part of the code (ie:
"Me.TextBox.PartnerName") when the error comes up.

(This sub is simply to open a new form, at the record already in the textbox
on the original form, actioned at the double click event)

I have checked other threads here to make sure the code is syntactically
correct, adn i think it is. Can anyone help?

Thanks
 
Hi,

if you want to filter form - then correct syntax is:

DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service=" &
Me("PartnerName")

or, if Me("PartnerName") is a string - then:

DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service='" &
Me("PartnerName") & "'"


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
You need to pass a string that looks like a where clause without the word
WHERE.

Try the following.
Assumptions:
PartnerName is the name of a textbox control on the current form.

Partner_Service is the name of a field that is being used in the record
source of frmPartners_entry
Partner_Service is a text field

DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service = " & Chr(34) &
Me.PartnerName & Chr(34)

That should build a string that looks like
Partner_Service = "Value in me PartnerName"
 
Thanks Alex,

Still not performing properly I'm afraid.

"PartnerName" is a TextBox containing a string, and is the control to which
this sub is attatched vis doubleclick. When I use your suggested:

DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service=" &
Me("PartnerName")..

....what happens is this: I get an Enter Parameter Value box coming up. If I
type the contents of PartnerName into this parameter request then, yes the
second form opens with the correct record. But the point is that I should not
have to retype the parameter in as it already exists in the textbox
"Partnername".

So: how to open new form with Partnername textbox value automatically passed
over as record filter?!

I think this is a matter of a minute syntax change, any suggestions?

Thanks again
 
John, thanks wow.

Thank works perfectly! Though I have to say I don't really understand the
whole "Chr(34)" thing.... I assumed that my problem would be so common as to
only involve really common commands. Ah well, you live and learn!

Thanks again
 
Chr(34) generates a quotation mark.

You could also use these other variations
Two quotation marks to get one quotation mark in the bult string
DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service = """ &
Me.PartnerName & """"

Or
Use an apostrophe in place of the quotation mark. This one is most
problematic since it will mess up if your partner name has an apostrophe in
it - for example, John's Diaper Service would error because the program
would think the name ended at John
DoCmd.OpenForm "frmPartners_Entry", , , "Partner_Service = '" &
Me.PartnerName & "'"
 
Hi

The reply from Mr Vinson below was perfect. But I need a little assistance
doing the same thing but with a number field, rather than a string. I want to
perform exactly the same effect, but use an ID field as the field in the
"where" clause.


Any further suggestions?
 
Back
Top