Filter a report

F

FPeix

I tried to filter a report in two field with a click button in a form with a
combobox and a list, I used the followed code:

Private Sub Command20_Click()
On Error GoTo Err_Command20_Click

Dim stDocName As String

stDocName = "rptmercobra2"
stLinkCriteria = "[Fornecedor]=" & "'" & Me![List0] & "'" And "[Obra]="
& "'" & Me![Combo17] & "'"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_Command20_Click:
Exit Sub


But, displays a message error "Type mismatch"

Where is the problem?
Help me

Thank you
Fernando
 
E

Eric Butts [MSFT]

Hi Fernando,

Compare the data type of the fields [Fornecedor] and [Obra]
and then compare the values they are be compared to Me![List0] and
Me![Combo17]

Very possible that the values (data types) being returned by Me![List0]
and/or Me![Combo17] are different from the fields in the table.


Regards,

Eric Butts
Microsoft Access Support
(e-mail address removed)
"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
<http://www.microsoft.com/security/security_bulletins/ms03-026.asp> and/or
to visit Windows Update at <http://windowsupdate.microsoft.com/> to install
the patch. Running the SCAN program from the Windows Update site will help
to insure you are current with all security patches, not just MS03-026."

This posting is provided "AS IS" with no warranties, and confers no rights

--------------------
| From: "FPeix" <[email protected]>
| Newsgroups: microsoft.public.access.reports
| Subject: Filter a report
| Date: Wed, 21 Jul 2004 13:25:22 +0100
| Organization: Netvisao, A sua Internet por Cabo
| Lines: 26
| Message-ID: <[email protected]>
| NNTP-Posting-Host: newsfront4.netvisao.pt
| X-Trace: newshub.netvisao.pt 1090411610 16289 213.228.128.120 (21 Jul
2004 12:06:50 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: Wed, 21 Jul 2004 12:06:50 +0000 (UTC)
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| X-NNTP-Posting-Host: ff1-84-90-15-89.netvisao.pt
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!nntp.cprm.net!newshub.netvisao.pt!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.access.reports:143139
| X-Tomcat-NG: microsoft.public.access.reports
|
| I tried to filter a report in two field with a click button in a form
with a
| combobox and a list, I used the followed code:
|
| Private Sub Command20_Click()
| On Error GoTo Err_Command20_Click
|
| Dim stDocName As String
|
| stDocName = "rptmercobra2"
| stLinkCriteria = "[Fornecedor]=" & "'" & Me![List0] & "'" And
"[Obra]="
| & "'" & Me![Combo17] & "'"
| DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
|
| Exit_Command20_Click:
| Exit Sub
|
|
| But, displays a message error "Type mismatch"
|
| Where is the problem?
| Help me
|
| Thank you
| Fernando
|
|
|
 
D

Duane Hookom

Regarding:
stLinkCriteria = "[Fornecedor]=" & "'" & Me![List0] & "'" And "[Obra]="
& "'" & Me![Combo17] & "'"
The And must be inside the quotes so try:
stLinkCriteria = "[Fornecedor]=""" & Me![List0] & """ And [Obra]=""" &
Me![Combo17] & """"
This assumes both fields are text and that List0 is not multi-select.

Please do yourself a favor and give your controls friendly names.
 

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