Type Mismatch - string

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi,

I'm having a problem with getting "Type Mismatch" ... I create sample code
but not sure if I did the right "setup" or not. Please help ?

Dim strGame as String
Dim strTeam as String
Dim Filter as String

strGame = "='No Game'" Or "='Cancellation'" >>> (is this correct ??)

strTeam = "='Baseball'"
Filter = "[Team] & strTeam & and "[Status] " & strGame

Your help would be much appreciated.
 
Hi,

I'm having a problem with getting "Type Mismatch" ... I create sample code
but not sure if I did the right "setup" or not. Please help ?

Dim strGame as String
Dim strTeam as String
Dim Filter as String

strGame = "='No Game'" Or "='Cancellation'" >>> (is this correct ??)

strTeam = "='Baseball'"
Filter = "[Team] & strTeam & and "[Status] " & strGame

Your help would be much appreciated.
It looks like you are trying to filter the form. There are a couple of
problems that I see.

You are declaring Filter as a variable - it is a Form property and
can't be use as a variable. You don't have a condition set to
determine what strGame should be. Also, your concatenation string is a
little off. Try something like this...

Dim strGame as String
Dim strTeam as String

If [your condition here] Then
strGame = "='No Game'"
Else
strGame = "='Cancellation'"
End If

strTeam = "='Baseball'"
Me.Filter = "[Team] & strTeam & " And [Status] " & strGame
Me.FilterOn = True

- Jim
 
No, the strGame isn't correct. A filter must be a valid WHERE clause
(without the word WHERE in it)

Your And must be inside the quotes to be accepted. As well, you can OR
together conditions like that.

Dim strGame as String
Dim strTeam as String
Dim Filter as String

strGame = "IN (''No Game' , 'Cancellation')"

strTeam = "='Baseball'"
Filter = "[Team] & strTeam &" and [Status] " & strGame

If you don't use the IN construct, you must repeat the field name, so that
you'd have to have:

Filter = "[Team]='Baseball' And ([Status]='No Game' Or
[Status]='Cancellation')
 
Hi Bill,

I wanted to post a quick note to see if you would like additional
assistance or information regarding this particular issue. We appreciate
your patience and look forward to hearing from you!

Sincerely yours,

Mingqing Cheng

Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
 
Back
Top