Parameter Error

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

Guest

Hi,
I am having a Problem with this particular peice of code, I want the program
to open a form that has a set of Or criteria, when i activate the code it
asks for input even though i told it to find it at my drop down menu here is
my code:
DoCmd.OpenForm "tblPropellant Query", , , "[AD1NAM]=" & "'Me!Additive' OR
[AD2NAM]=" & "'Me!Additive'"
Thanks,
James
 
Hi,
I am having a Problem with this particular peice of code, I want the program
to open a form that has a set of Or criteria, when i activate the code it
asks for input even though i told it to find it at my drop down menu here is
my code:
DoCmd.OpenForm "tblPropellant Query", , , "[AD1NAM]=" & "'Me!Additive' OR
[AD2NAM]=" & "'Me!Additive'"
Thanks,
James

Your quotes are not correct.

What are the datatypes of Additive and ad2nam?
If they are both Text, then:

"[AD1NAM]= ' " & Me!Additive & " ' OR
[AD2NAM]= ' " & Me!Additive & " ' "

I've inserted a space between the single and double quotes just for
clarity. Remove the spaces.

However, if the datatypes of both fields are Number, then use:

"[AD1NAM]= " & Me!Additive & " OR
[AD2NAM]= " & Me!Additive
 
fredg,

I think I changed the code correctly, but now it has a data type missmatch,
I thought that the data type was text but I am not sure, how do I check?
just in case here is my code:

Private Sub Additive_Click()

DoCmd.OpenForm "tblPropellant Query", , , "[AD1NAM]='" & Me!Additive Or
"[AD2NAM]='" & Me!Additive & "'"

End Sub

-James

fredg said:
Hi,
I am having a Problem with this particular peice of code, I want the program
to open a form that has a set of Or criteria, when i activate the code it
asks for input even though i told it to find it at my drop down menu here is
my code:
DoCmd.OpenForm "tblPropellant Query", , , "[AD1NAM]=" & "'Me!Additive' OR
[AD2NAM]=" & "'Me!Additive'"
Thanks,
James

Your quotes are not correct.

What are the datatypes of Additive and ad2nam?
If they are both Text, then:

"[AD1NAM]= ' " & Me!Additive & " ' OR
[AD2NAM]= ' " & Me!Additive & " ' "

I've inserted a space between the single and double quotes just for
clarity. Remove the spaces.

However, if the datatypes of both fields are Number, then use:

"[AD1NAM]= " & Me!Additive & " OR
[AD2NAM]= " & Me!Additive
 
fredg,

I figured it out, I used AD1NAM instead of A1NAM, that had screwed it up,
but without your post the code would still have been wrong Thanks!
James


James said:
fredg,

I think I changed the code correctly, but now it has a data type missmatch,
I thought that the data type was text but I am not sure, how do I check?
just in case here is my code:

Private Sub Additive_Click()

DoCmd.OpenForm "tblPropellant Query", , , "[AD1NAM]='" & Me!Additive Or
"[AD2NAM]='" & Me!Additive & "'"

End Sub

-James

fredg said:
Hi,
I am having a Problem with this particular peice of code, I want the program
to open a form that has a set of Or criteria, when i activate the code it
asks for input even though i told it to find it at my drop down menu here is
my code:
DoCmd.OpenForm "tblPropellant Query", , , "[AD1NAM]=" & "'Me!Additive' OR
[AD2NAM]=" & "'Me!Additive'"
Thanks,
James

Your quotes are not correct.

What are the datatypes of Additive and ad2nam?
If they are both Text, then:

"[AD1NAM]= ' " & Me!Additive & " ' OR
[AD2NAM]= ' " & Me!Additive & " ' "

I've inserted a space between the single and double quotes just for
clarity. Remove the spaces.

However, if the datatypes of both fields are Number, then use:

"[AD1NAM]= " & Me!Additive & " OR
[AD2NAM]= " & Me!Additive
 
Back
Top