Where Condition

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a form where one of the buttons prompts the user to enter
information. I would like this form to behave as follows:

1. The user types in the required information (This works)
2. The user can either enter in part of the information or hit enter to get
all of it. (This doesn't work)

I know I am close...I keep getting the "Run-time error 13": Type
mismatch...Could someone review my code. I'm hoping a fresh pair of eyes
will find the problem...

DoCmd.OpenReport "MyForm", acViewPreview, , "[Year] = 2003 and [Template
Version] Like [Enter Template Version or part of it] & " * ""

Thanks
 
I have created a form where one of the buttons prompts the user to enter
information. I would like this form to behave as follows:

1. The user types in the required information (This works)
2. The user can either enter in part of the information or hit enter to get
all of it. (This doesn't work)

I know I am close...I keep getting the "Run-time error 13": Type
mismatch...Could someone review my code. I'm hoping a fresh pair of eyes
will find the problem...

DoCmd.OpenReport "MyForm", acViewPreview, , "[Year] = 2003 and [Template
Version] Like [Enter Template Version or part of it] & " * ""

Thanks

As written, this will return records where the [Template Version]
STARTS with the user input, and contains one blank after the user
input.

Try instead:

DoCmd.OpenReport "MyForm", acViewPreview, , "[Year] = 2003 and
[Template Version] Like ""*"" & [Enter Template Version or part of it]
& ""*"""


John W. Vinson[MVP]
 
Year is a poor choice as a column name since it is the name of a Function().
You should not use any reserved words as object names, especially property
and function names.
 
John

You have been away from the newsgroups for too long?

I guess it should be:

DoCmd.OpenReport "MyForm", acViewPreview, , "[Year] = 2003 and
[Template Version] Like ""*" & [Enter Template Version or part of it]
& "*"""

Cheers
Van
 
Van,

I tried your code, however, now I don't get any results no matter what I
type in the dialog box....any suggestions?

Thanks

Van T. Dinh said:
John

You have been away from the newsgroups for too long?

I guess it should be:

DoCmd.OpenReport "MyForm", acViewPreview, , "[Year] = 2003 and
[Template Version] Like ""*" & [Enter Template Version or part of it]
& "*"""

Cheers
Van




John Vinson said:
As written, this will return records where the [Template Version]
STARTS with the user input, and contains one blank after the user
input.

Try instead:

DoCmd.OpenReport "MyForm", acViewPreview, , "[Year] = 2003 and
[Template Version] Like ""*"" & [Enter Template Version or part of it]
& ""*"""


John W. Vinson[MVP]
 
Do you have the Fields [Year] (Numeric) and [Template Version] (Text) in the
RecordSource of the Report "MyForm" (??? seems to be inconsistent naming
convention here).

To avoid typing mistakes with code on newsgroup posts, it is much better
(and quicker) to simply copy the relevant code from your database and paste
it on the post.
 
Back
Top