Hi Every One
I am New to the discoution, My problem is:
I am trying to filter a report by using cambo box and Comand bottons, Combo Box to set the filter value bottens for close,clear and apply filter to report.always getting type mismatch runtime error 13 when i debug error it hi light this line
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & "" _
And ""
Which it is part of this code
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 3
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) - 3))
' Set the Filter property.
Reports![rptTransactions].Filter = strSQL
Reports![rptTransactions].FilterOn = True
End If
End Sub
Can Some 1 help me fix this problem?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..
11 1979
Hi Every One
I am New to the discoution, My problem is:
I am trying to filter a report by using cambo box and Comand bottons, Combo Box to set the filter value bottens for close,clear and apply filter to report.always getting type mismatch runtime error 13 when i debug error it hi light this line
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & "" _
And ""
Which it is part of this code
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 3
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) - 3))
' Set the Filter property.
Reports![rptTransactions].Filter = strSQL
Reports![rptTransactions].FilterOn = True
End If
End Sub
Can Some 1 help me fix this problem?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!..
Hey Iyhamid, Welcome to theScripts. im going to move this to the SQL forum. Have a nice day.
Hi All,
I think the thread may be happier in the access forum.
Regards Purple
Good morning lyhamid,
First of all, what version of what program are you using?
Second, what is the output you would like to see from this strSQL statement?
i.e. [Filter1] = "Filter1" or something like that?
Regards,
Scott
Hello
I am Using Access Of Office 2003, Filter1 is A merchant ID contain of 8 numbers..
Thanks
- Private Sub Set_Filter_Click()
-
Dim strSQL As String, intCounter As Integer
-
-
' Build SQL String.
-
For intCounter = 1 To 3
-
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) - 3))
-
-
' Set the Filter property.
-
Reports![rptTransactions].Filter = strSQL
-
Reports![rptTransactions].FilterOn = True
-
End If
-
-
End Sub
You haven't explained all the information we really need yet, but I'm going to make some assumptions.
Assumption #1: "Filter" in your code is referring to a control on your form. In this case you need to refer to it in this way: Me!Filter.
To build your strSQL, you want it to look more like this: - strSQL = "[" & Me!Filter & intCounter & "]" = & Chr$(34) & Me!Filter & intCounter & Chr$(34) & " And "
You have it set to add " And " at the end of your filter string, and then are trying to take those characters away later if a condition is not met. The problem is, your code won't take them all away! Your code will only take the furthest right three characters, which will leave the space and capital A intact. Maybe that's what you intend, otherwise you'll need to increase your character count to 5 (remember VBA counts a space within a string as a character) in your Left() statement.
Your Next statement needs to look more like this: Next intCounter
Make these few changes, then please let me know if it works!
Regards,
Scott
I will Try that when i go to work 2morrow.. i got this code from this site..
http://support.microsoft.com/?kbid=208529..
Thanks Man i will get back to you asap..
Hello Scott:
Sorry I didn't Fully explain setuation..(Set Filter) is a command Botten to run the previouse code..
Combo Boxes named Filter1, Filter2, Filter3 and Taged as Merchant Id,Date and transaction ID. The program call it by Tages when u loop the counter.. Also the form open the rpttransactions report.. The form that filtered by filter1, filter2 and filter3
When I put ur code it came with syntax error
strSQL = "[" & Me!Filter & intCounter & "]" = & Chr$(34) & Me!Filter & intCounter & Chr$(34) & " And "
Thanks
Iehab
Hello Scott I got a diffrent error after I change it alittle bite, But now I am getting the Filter1 value and the others value but it will say value no valid even if i get it from the report..I change it to:
strSQL = "[" & Me("Filter" & intCounter).Tag & "]" & Chr$(34) & Me("Filter" & intCounter) & Chr$(34) & " And "
Thanks
Iehab
Hello Scott I got a diffrent error after I change it alittle bite, But now I am getting the Filter1 value and the others value but it will say value no valid even if i get it from the report..I change it to:
strSQL = "[" & Me("Filter" & intCounter).Tag & "]" & Chr$(34) & Me("Filter" & intCounter) & Chr$(34) & " And "
Thanks
Iehab
Good morning!
Did you download the sample Access 2000 report on this link? Access 2000 Sample Reports
I downloaded their sample, and it runs perfectly using the data setup they provide in the sample database. (by the way, thanks for pointing out that link, the sample db has some pretty handy things avail. in it)
Since it runs fine for me, I'm wondering if you have a broken reference in the combo boxes that set the filter values, and/or a data type mismatch problem in the fields you are trying to sort on.
Please check each one carefully to make sure your combo boxes match exactly the fields on the report, check to make sure you have each field matched to the data it is sorting (i.e. that you haven't tried to pass a string value to a number field on your report.)
Post back to let me know how it goes.
Regards,
Scott
Thank Scott it is working like a charm now i had to change a little in the code u gave me and know it look like this:
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr$(34) & Me("Filter" & intCounter) & Chr$(34) & " And "
Thanks again
Thank Scott it is working like a charm now i had to change a little in the code u gave me and know it look like this:
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr$(34) & Me("Filter" & intCounter) & Chr$(34) & " And "
Thanks again
Glad it's working for you!
Regards,
Scott
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
I am trying to filter records in a primary form based on records in
related tables. The data in the related tables is being displayed in
the primary form
through subforms. To be more specific, I...
|
by: Elias Farah |
last post by:
Hello All,
I hope someone can give me (and other keen access enthusiasts) some
helpful information to explain how to most efficiently filter Queries
& subqueies.
Consider this common simple...
|
by: Keith Shearer |
last post by:
I'm having a bit of trouble, moving between controls, when filtering on a
form.
I'm using a continuous form. At the top I have 2 date fields. I want to
filter the data specified between the two...
|
by: Richard |
last post by:
Hi,
I have a form that take some time to load due to many comboboxes and at
least 8 subforms.
When I filter or sort the main form I get an error message and then Access
shuts down. They ask if...
|
by: sensible |
last post by:
Can I solve this problem using Access? If so, will some give this
newbie a simple step by step on how to go about it, please....all the
way from File/New.
In Excel I am using...
|
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I...
|
by: Shawn Ramirez |
last post by:
As with most web applications speed is a huge deal to me in my applications.
My customers don't really care if my app is a true 3 tier application or not,
they just want it to be faster then it was...
|
by: Jimmy |
last post by:
Hi!
I'm looking for a library with methods for filtering user input in a
web application. I mean, some API which gives more functionality than
the traditional .NET validation controls.
Any...
|
by: Yarik |
last post by:
Hello,
Here is a sample (and very simple) code that binds an Access 2003 form
to a fabricated ADO recordset:
' Create recordset...
Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset
'...
|
by: Lyn |
last post by:
I have a problem using the form .Filter and .FilterOn properties which
causes Access to crash (as detailed in a separate post). The form operates
in continuous mode, displaying matching records...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |