Open Form Based on Multiple Conditions

  • Thread starter Thread starter Todd Shillam
  • Start date Start date
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
 
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 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
 
Back
Top