We help IT Professionals succeed at work.

Access VBA syntax for report

Robert Wardlow
on
Thank you in advance for your help.
I am having so much trouble figuring out the syntax for different combinations of criteria

I am trying to print a report and limit the results to the value of 2 text fields

Below is the syntax I created but it is producing a type mismatch.


strLinkCriteria = "[Property Address 1]='" & Me![Property Address 1] & "' " And "[Owner of Property]= '" & Me![Owner of Property] & "'"

What am I doing wrong?

Thank you for your help
Bob


Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
If you are storing propery owner by an ID field, try this instead:

strLinkCriteria = "[Property Address 1]='" & Me![Property Address 1] & "' " And "[Owner of Property]= " & Me![Owner of Property]
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
You also have mis matched quotes.

Try this:

strLinkCriteria = "[Property Address 1]='" & Me![Property Address 1] & "'  And [Owner of Property]= '" & Me![Owner of Property] & "'"

Or this if propery owner is stored as a numeric ID:

strLinkCriteria = "[Property Address 1]='" & Me![Property Address 1] & "'  And [Owner of Property]= " & Me![Owner of Property]


Robert WardlowPresident

Author

Commented:
Thanks for your suggestion. But that still gave a type mismatch error.

What do you mean by an ID field?  Both fields are text fields.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013
Commented:
Okay, then use this:

strLinkCriteria = "[Property Address 1]='" & Me![Property Address 1] & "'  And [Owner of Property]= '" & Me![Owner of Property] & "'"

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013

Commented:
>> What do you mean by an ID field?

That generally means that you have an employees table with a numeric Primary key (automumber) associated with each emplyee, and that you are storing that numeric field as a 'foreign key' in other tables in your database instead of the actual text name.
Robert WardlowPresident

Author

Commented:
Perfect, thank you very much.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.