Run-time error '2465'

whojstall11

Registered User.
Local time
Today, 01:14
Joined
Sep 7, 2011
Messages
94
I have a code that giving me the run time error can anybody help
PHP:
Private Sub Command7_Click()
Dim strFilter As Integer

strFilter = [PO Number] = [Forms]![PO Search Report]!PONumber
DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
[PO Number] = Me!PONumber.Value

End Sub

I know it has something to do with the data type integer but I dont know how to fix it.
 
Code:
Private Sub Command7_Click() 
Dim strFilter As [B][COLOR=red]String[/COLOR][/B]
 
strFilter = [B][COLOR=red]"[/COLOR][/B][PO Number] =[B][COLOR=red]" &[/COLOR][/B] [Forms]![PO Search Report]!PONumber 
DoCmd.OpenReport "Purchase Order Report", acViewReport, , [B][COLOR=red]strFilter[/COLOR][/B]
 
End Sub

If the command button is on PO Search Report, then you just need:

Code:
Private Sub Command7_Click() 
Dim strFilter As [B][COLOR=red]String[/COLOR][/B]
 
strFilter = [B][COLOR=red]"[/COLOR][/B][PO Number] =[B][COLOR=red]" &[/COLOR][/B] [B][COLOR=blue][PONumber ][/COLOR][/B]
DoCmd.OpenReport "Purchase Order Report", acViewReport, , [B][COLOR=red]strFilter[/COLOR][/B]
 
End Sub
 
Ok i tried to combine both ways still no luck
PHP:
strFilter = "[PO Number] =" & [Forms]![PO Search Report]!PONumber

DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
"[PO Number] ='" & Me.PONumber & "'" & " or DateOrdered ='" & Me.DateOrdered & "'"

and it gives me an syntax error when I but in # for the dateordered
 
Ok i tried to combine both ways still no luck
PHP:
strFilter = "[PO Number] =" & [Forms]![PO Search Report]!PONumber
 
DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
"[PO Number] ='" & Me.PONumber & "'" & " or DateOrdered ='" & Me.DateOrdered & "'"

What the heck? You didn't show DateOrdered in there at all before.

And why the hell are you creating the strFilter if you aren't going to use it?

And Dates don't get quotes surrounding them, they get octothorpes (#).

And you don't have the keyword AND in between the two:

Code:
strFilter = "[PO Number] =" & Me.PONumber & " AND [DateOrdered]=#" & Me.DateOrdered & "#"
 
DoCmd.OpenReport "Purchase Order Report", acViewReport, , strFilter

Also, why are you posting using the PHP tags instead of the CODE tags which is the one with the # on the button?
 
Yea make sense but it should be an "or" instead of an "and" i want people to be able to search by either. When i add an "or" i get runtime error 3075
 
Is PO Number a number or is it text? If it is text then it needs quotes.

And how is the date stored? Are you using mm/dd/yyyy or dd/mm/yyyy?
 
Po is a number an date i use the date picker and its mm/dd/yyyy
 
I took out the strFilter too
Code:
Private Sub Command7_Click()
DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
"PO Number =" & Me!PONumber.Value & " or [DateOrdered]=#" & DateOrdered.Value & "#"

End Sub
 
Slight change:

Code:
Private Sub Command7_Click()
DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
"PO Number =" & Me!PONumber & " or [DateOrdered]=#" & [B][COLOR=red]Me![/COLOR][/B]DateOrdered & "#"

End Sub
You don't need the .Value part either as that is the default.

But another question came up - is the PONumber field and the DateOrdered field on the same form as the command button? Or is it in a subform?
 
You have to bracket the field name due to the inadvisable space:

[PO Number]
 
You have to bracket the field name due to the inadvisable space:

[PO Number]

I'm on it today (NOT!!!)
headinhands.jpg
 
Earlier versions had the brackets, but apparently they got dropped along the way.
 
Yea they are both on the same from as the button. Im getting an "Syntax error (missing operator in query expression 'PO Number = 3011 or [DateOrdered]=##)' "
 
Yea they are both on the same from as the button. Im getting an "Syntax error (missing operator in query expression 'PO Number = 3011 or [DateOrdered]=##)' "

Okay, that shows two problems.

1. Which Paul pointed out, you need brackets around the PO Number part of the code. [PO Number]=

2. And your form has no date selected. It is showing the # from both sides but there is no date. Select a date on your form and move to another control from that control.
 
Yea doesnt work either
Code:
Private Sub Command7_Click()
DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
"[PO Number]=" & Me!PONumber & " or [DateOrdered]=#" & Me!DateOrdered & "#"

End Sub
 
Yea doesnt work either
Code:
Private Sub Command7_Click()
DoCmd.OpenReport "Purchase Order Report", acViewReport, , _
"[PO Number]=" & Me!PONumber & " or [DateOrdered]=#" & Me!DateOrdered & "#"
 
End Sub
So you have actually selected a date in the control which is named DateOrdered? If that is not the name of the control which you are using to select the date, then replace it with the actual name of the control you are using.

If you are getting the error about syntax which shows this:

or [DateOrdered]=##)' "

then it means that there is no value in the control which you are using for your date selection. You need to look into why that is the case.
 

Users who are viewing this thread

Back
Top Bottom