Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering Report with a Form (Different Question)

Status
Not open for further replies.

edgarchado

Technical User
Apr 5, 2005
59
AR
Hi to all,

I have found in the web a microsoft example how to filter a report using combo boxes in a form.

I have found it to be really usefull for what I need to do.

The problem is that I ma having trouble with the data type.

Here is the code for the filter command button:

Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 2
If Me("Filter" & intCounter) <> "" Then

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & _
" And "
End If
Next

If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property.
Reports![infReporte_Pedidos].Filter = strSQL
Reports![infReporte_Pedidos].FilterOn = True
End If

End Sub


The problem is that I am trying to filter using a date and an autonumber. The data type for the date in my table is DATA and the data type for the number is autonumber.

If I change the datatype of the date to char I have no problem when filtering. On the other hand I can not seem to find the problem with the number. I would like to leave the datatypes as i intended originally. Is there a way to put something in the code so i dont have to change the data types?

Thanks and i hope i am clear enough.
 
For date datatypes you would replace [blue]Chr(34)[/blue] with [blue]"#"[/blue].

For numeric datatypes, you would remove the Chr(34).

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
dhookm,

Thanks once again for your answer. I though no one would understand what I was trying to say.

I have tried changing the code with what you told me but I had no luck.

could you please show me how to do it in my code?

Here it is:

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & _
" And "

The exact error I get is: Sintax Error (operator missing) in expresion '([Fecha_de_Entrega] = #08/04/2005 And [N°_de_Pedido] = #92)'

Thanks.
 
I don't know what all the code is. I think it is from one of the FAQs here so you would be best advised to try email the contributer directly. I would rather not try to troubleshoot someone trying to use someone else's code. If you want to use the code, you should try to understand it.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks anyway. I Found out how to solve my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top