Open Form Based on Multiple Conditions

T

Todd Shillam

I know how to open a form based on single criteria, for example:

Dim strForm As String
Dim strCriteria As String

strForm = "frmAddRecord"
strCriteria = "[LinkID]=" & Me.txtLinkID

DoCmd.OpenForm strForm,,strCriteria

However, I want to have multiple criteria, more than one. Any help would be
greatly appreciated.

Thanks,

Todd
 
R

Rick Brandt

Todd said:
I know how to open a form based on single criteria, for example:

Dim strForm As String
Dim strCriteria As String

strForm = "frmAddRecord"
strCriteria = "[LinkID]=" & Me.txtLinkID

DoCmd.OpenForm strForm,,strCriteria

However, I want to have multiple criteria, more than one. Any help
would be greatly appreciated.

Just use "And" and/or "Or" just as you would in a query. If it's easier create
a query that returns what you want, switch to SQL view and copy the WHERE clause
leaving off the word "where".

Ex:

strCriteria = "[LinkID]=" & Me.txtLinkID & " AND [SomeOtherField]='"
Me.SomeOtherControl & "'"
 
T

Todd Shillam

Rick Brandt said:
Todd said:
I know how to open a form based on single criteria, for example:

Dim strForm As String
Dim strCriteria As String

strForm = "frmAddRecord"
strCriteria = "[LinkID]=" & Me.txtLinkID

DoCmd.OpenForm strForm,,strCriteria

However, I want to have multiple criteria, more than one. Any help
would be greatly appreciated.

Just use "And" and/or "Or" just as you would in a query. If it's easier
create a query that returns what you want, switch to SQL view and copy the
WHERE clause leaving off the word "where".

Ex:

strCriteria = "[LinkID]=" & Me.txtLinkID & " AND [SomeOtherField]='"
Me.SomeOtherControl & "'"

Rick,

Your awesome! Thanks for the help--I haven't had much need to get this
complex until recently. I'm working with a slew of junction tables in a
project I am working on--so you've been very helpful. Thanks again.

Best regards,

Todd
 

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