Run-time error 13 (in a pop-up form)

G

Guest

I used the instructions from support article 208529 ("How to Filter a Report
from a Pop-Up Form") and modified it for my report. When I open the form,
the Print Preview comes up behind the Pop-up, like it is supposed to. But,
when I choose a variable in the combo box, then click the Set Filter button,
I get the following error:

Run-time error '13': Type mismatch

When I click on Debug, the highlighted part of the Visual Basic screen is:

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

with the yellow arrow pointing at the third line.

Can you tell me what could be wrong? Thanks!

my email is slegg(remove this)@earthlink.net
 
D

Dirk Goldgar

Susan Bohannon said:
I used the instructions from support article 208529 ("How to Filter a
Report from a Pop-Up Form") and modified it for my report. When I
open the form, the Print Preview comes up behind the Pop-up, like it
is supposed to. But, when I choose a variable in the combo box, then
click the Set Filter button, I get the following error:

Run-time error '13': Type mismatch

When I click on Debug, the highlighted part of the Visual Basic
screen is:

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

with the yellow arrow pointing at the third line.

Can you tell me what could be wrong? Thanks!

It looks like the KB article made a mistake in the code it presented,
trying to continue a line in the middle of a string. Try this:

'----- start of corrected code -----

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

'----- end of corrected code -----
 
G

Guest

I did this change as you suggested and it worked! What a relief.

Thank you SO much!

Dirk Goldgar said:
Susan Bohannon said:
I used the instructions from support article 208529 ("How to Filter a
Report from a Pop-Up Form") and modified it for my report. When I
open the form, the Print Preview comes up behind the Pop-up, like it
is supposed to. But, when I choose a variable in the combo box, then
click the Set Filter button, I get the following error:

Run-time error '13': Type mismatch

When I click on Debug, the highlighted part of the Visual Basic
screen is:

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

with the yellow arrow pointing at the third line.

Can you tell me what could be wrong? Thanks!

It looks like the KB article made a mistake in the code it presented,
trying to continue a line in the middle of a string. Try this:

'----- start of corrected code -----

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

'----- end of corrected code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
R

Run-Time Error 13

I used the same code and keep coming up with the error Message;

Extra ) in query expression '([] = "This is my filter data"And)'


Here is the code I am using;
'Start-----------

Private Sub Command4_Click()
Dim strSQL As String, intCounter As Integer

' Build SQL String.
For intCounter = 1 To 1
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) - 1))

' Set the Filter property.
Reports![Transactions Individual].Filter = strSQL
Reports![Transactions Individual].FilterOn = True
End If
End Sub

'End Code--------

Not really sure if this is the code i should be using for the application or
not. I am only using 1 Combobox as filter. Not sure if that makes a
difference.
 
D

Douglas J. Steele

Just before you set the Filter property, add the line of code:

Debug.Print strSQL

When your code runs (and fails), go to the Immediate Window (Ctrl-G). What
appears there?
 

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

Top