Parameter Error

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

Guest

Hi there, using A02 on XP.

I have a double primary key for my unique value. Record is on subform for
editing, validation and print. Click a button to preview the report after
editing complete. Copied some wordage and put my rpt and field names in. But,
when I try to run, I get the parameter box. I know this is a quotes issue but
can't figure out where I've run amok.

DoCmd.OpenReport "rSAR", acViewPreview, , "[PlanNum]=" & Me![PlanNum] & "
AND [PlanYear]=""" & Me.[PlanYear] & """"

Could someone look at this and tell me what I'm doing wrong? Remember trying
this recently but cannot find my notes.

Thanks in advance for any help or advice!
 
Hi there, using A02 on XP.

I have a double primary key for my unique value. Record is on subform for
editing, validation and print. Click a button to preview the report after
editing complete. Copied some wordage and put my rpt and field names in. But,
when I try to run, I get the parameter box. I know this is a quotes issue but
can't figure out where I've run amok.

DoCmd.OpenReport "rSAR", acViewPreview, , "[PlanNum]=" & Me![PlanNum] & "
AND [PlanYear]=""" & Me.[PlanYear] & """"

Could someone look at this and tell me what I'm doing wrong? Remember trying
this recently but cannot find my notes.

What are the datatypes of PlanNum and PlanYear? As written this should
work OK if PlanNum is a Number or Autonumber datatype, and PlanYear is
Text. Is the button on the Subform, or the main form?

John W. Vinson[MVP]
 
Hi John,

Sorry to leave out the details. Both fields are text. The button is on my
subform (where the current record is displayed). My parameter box opens and
it reads the PlanNum contents where you would normally put your inquiry line.

I've got the entire DB ready to go if I can just get the report to open with
data from the showing record by linking with the 2 fields.

Thanks again for your interest, I'll wait anxiously for your reply.
 
Hi John,

Sorry to leave out the details. Both fields are text. The button is on my
subform (where the current record is displayed). My parameter box opens and
it reads the PlanNum contents where you would normally put your inquiry line.

I've got the entire DB ready to go if I can just get the report to open with
data from the showing record by linking with the 2 fields.

Thanks again for your interest, I'll wait anxiously for your reply.

Text fields need either ' or " as a delimiter; if the field will never
contain an apostrophe, it's a bit easier to include the '. You've
correctly figured out how to double up a doublequote to get a single
doublequote (how's that for doubletalk!) but in this case, just use ':

DoCmd.OpenReport "rSAR", acViewPreview, , "[PlanNum]='" & Me![PlanNum]
& "' AND [PlanYear]='" & Me.[PlanYear] & "'"

This will translate to something like

[PlanNum]='X123' AND [PlanYear]='2004'

and should work for you.

John W. Vinson[MVP]
 
You are a genius! Thank you VERY much. It appears I was copying VB with one
text and one number field. Duh! I needed both to be text here. The
single-double, no double-double, ye gads! The light bulb just hasn't come on
yet. But I'm workin' on it!

Thanks again for being here for folks like me!!! LUV THESE NEWSGROUPS!
--
Bonnie


John Vinson said:
Hi John,

Sorry to leave out the details. Both fields are text. The button is on my
subform (where the current record is displayed). My parameter box opens and
it reads the PlanNum contents where you would normally put your inquiry line.

I've got the entire DB ready to go if I can just get the report to open with
data from the showing record by linking with the 2 fields.

Thanks again for your interest, I'll wait anxiously for your reply.

Text fields need either ' or " as a delimiter; if the field will never
contain an apostrophe, it's a bit easier to include the '. You've
correctly figured out how to double up a doublequote to get a single
doublequote (how's that for doubletalk!) but in this case, just use ':

DoCmd.OpenReport "rSAR", acViewPreview, , "[PlanNum]='" & Me![PlanNum]
& "' AND [PlanYear]='" & Me.[PlanYear] & "'"

This will translate to something like

[PlanNum]='X123' AND [PlanYear]='2004'

and should work for you.

John W. Vinson[MVP]
 

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

Back
Top