Two link criteria

C

Chris

I have a client form where I call via a button a second form showing
personnel at the client's location. Presently, I link via the client's
location and this works fine.

However, I have personnel "affiliated" with other personnel and only desire
to show those affiliated and in that location.

I know I can add a second criteria, can't seem to get it right! Can ya
help? I have tried:

stLinkCriteria = "[Location]=" & "'" & Me![cboLocation] & "'" And
"[PSAffiliatedWith]=" & Me![MasterPS] & "'"

All fields are text boxes.

From the client's form:
cboLocation
MasterPS

From the called location form:
Location
PSAffiliatedWith

I got very confused with the single and double quotes.
 
T

tina

try

stLinkCriteria = "[Location] = '" & Me![cboLocation] & _
"' And [PSAffiliatedWith] = '" & Me![MasterPS] & "'"

hth
 
J

Joshua A. Booker

Chris,

Try this:

stLinkCriteria = "[Location]='" & Me![cboLocation] & "' And
[PSAffiliatedWith]='" & Me![MasterPS] & "'"

Assuming both fiields are text. If they are number you don't need double
quotes.
Sometimes it helps to print the stLinkCriteria to the debug window so you
can spot missing quotes.

Add this code to do that:

debug.print stLinkCriteria

HTH,
Josh
 
C

Chris

Did the trick. Thanks so much.
--
Thanks for your help,
Chris


tina said:
try

stLinkCriteria = "[Location] = '" & Me![cboLocation] & _
"' And [PSAffiliatedWith] = '" & Me![MasterPS] & "'"

hth


Chris said:
I have a client form where I call via a button a second form showing
personnel at the client's location. Presently, I link via the client's
location and this works fine.

However, I have personnel "affiliated" with other personnel and only desire
to show those affiliated and in that location.

I know I can add a second criteria, can't seem to get it right! Can ya
help? I have tried:

stLinkCriteria = "[Location]=" & "'" & Me![cboLocation] & "'" And
"[PSAffiliatedWith]=" & Me![MasterPS] & "'"

All fields are text boxes.

From the client's form:
cboLocation
MasterPS

From the called location form:
Location
PSAffiliatedWith

I got very confused with the single and double quotes.
 
C

Chris

Did the trick. Thanks so much.
--
Thanks for your help,
Chris


Joshua A. Booker said:
Chris,

Try this:

stLinkCriteria = "[Location]='" & Me![cboLocation] & "' And
[PSAffiliatedWith]='" & Me![MasterPS] & "'"

Assuming both fiields are text. If they are number you don't need double
quotes.
Sometimes it helps to print the stLinkCriteria to the debug window so you
can spot missing quotes.

Add this code to do that:

debug.print stLinkCriteria

HTH,
Josh

Chris said:
I have a client form where I call via a button a second form showing
personnel at the client's location. Presently, I link via the client's
location and this works fine.

However, I have personnel "affiliated" with other personnel and only desire
to show those affiliated and in that location.

I know I can add a second criteria, can't seem to get it right! Can ya
help? I have tried:

stLinkCriteria = "[Location]=" & "'" & Me![cboLocation] & "'" And
"[PSAffiliatedWith]=" & Me![MasterPS] & "'"

All fields are text boxes.

From the client's form:
cboLocation
MasterPS

From the called location form:
Location
PSAffiliatedWith

I got very confused with the single and double quotes.
 
T

tina

you're welcome :)

btw, Chris, one way to help you figure out the placement of quotes is to
start by hard-coding the values, as

[Location] = something And [PSAffiliatedWith] = something else

the entire criteria expression is a string, so enclose it in double quotes,
as

"[Location] = something And [PSAffiliatedWith] = something else"

your values are text data type, so enclose them in single quotes, as

"[Location] = 'something' And [PSAffiliatedWith] = 'something else'"

since the values will be pulled from fields, rather than hard-coded, they
must be *outside* the string, while the single quotes must remain *inside*
the string, as

"[Location] = '" something "' And [PSAffiliatedWith] = '" something else "'"

now you have a series of little strings that must be connected
(concatenated), as

"[Location] = '" & something _
& "' And [PSAffiliatedWith] = '" _
& something else & "'"

<putting the line-break character ( _ ) in just makes sure that you can see
how the string fits together in this post, since a too-long line will
automatically wrap and that can be confusing.>

now that the strings are concatenated, just replace the hard-coded values
with the field references, as

"[Location] = '" & Me!cboLocation _
& "' And [PSAffiliatedWith] = '" _
& Me!MasterPS & "'"

hth


Chris said:
Did the trick. Thanks so much.
--
Thanks for your help,
Chris


tina said:
try

stLinkCriteria = "[Location] = '" & Me![cboLocation] & _
"' And [PSAffiliatedWith] = '" & Me![MasterPS] & "'"

hth


Chris said:
I have a client form where I call via a button a second form showing
personnel at the client's location. Presently, I link via the client's
location and this works fine.

However, I have personnel "affiliated" with other personnel and only desire
to show those affiliated and in that location.

I know I can add a second criteria, can't seem to get it right! Can ya
help? I have tried:

stLinkCriteria = "[Location]=" & "'" & Me![cboLocation] & "'" And
"[PSAffiliatedWith]=" & Me![MasterPS] & "'"

All fields are text boxes.

From the client's form:
cboLocation
MasterPS

From the called location form:
Location
PSAffiliatedWith

I got very confused with the single and double quotes.
 
C

Chris

Thanks Tina, that does help me a great deal. Thanks for taking the time
helping me.
--

Chris


tina said:
you're welcome :)

btw, Chris, one way to help you figure out the placement of quotes is to
start by hard-coding the values, as

[Location] = something And [PSAffiliatedWith] = something else

the entire criteria expression is a string, so enclose it in double quotes,
as

"[Location] = something And [PSAffiliatedWith] = something else"

your values are text data type, so enclose them in single quotes, as

"[Location] = 'something' And [PSAffiliatedWith] = 'something else'"

since the values will be pulled from fields, rather than hard-coded, they
must be *outside* the string, while the single quotes must remain *inside*
the string, as

"[Location] = '" something "' And [PSAffiliatedWith] = '" something else "'"

now you have a series of little strings that must be connected
(concatenated), as

"[Location] = '" & something _
& "' And [PSAffiliatedWith] = '" _
& something else & "'"

<putting the line-break character ( _ ) in just makes sure that you can see
how the string fits together in this post, since a too-long line will
automatically wrap and that can be confusing.>

now that the strings are concatenated, just replace the hard-coded values
with the field references, as

"[Location] = '" & Me!cboLocation _
& "' And [PSAffiliatedWith] = '" _
& Me!MasterPS & "'"

hth


Chris said:
Did the trick. Thanks so much.
--
Thanks for your help,
Chris


tina said:
try

stLinkCriteria = "[Location] = '" & Me![cboLocation] & _
"' And [PSAffiliatedWith] = '" & Me![MasterPS] & "'"

hth


I have a client form where I call via a button a second form showing
personnel at the client's location. Presently, I link via the client's
location and this works fine.

However, I have personnel "affiliated" with other personnel and only
desire
to show those affiliated and in that location.

I know I can add a second criteria, can't seem to get it right! Can ya
help? I have tried:

stLinkCriteria = "[Location]=" & "'" & Me![cboLocation] & "'" And
"[PSAffiliatedWith]=" & Me![MasterPS] & "'"

All fields are text boxes.

From the client's form:
cboLocation
MasterPS

From the called location form:
Location
PSAffiliatedWith

I got very confused with the single and double quotes.
 
T

tina

that example will probably get you through 95% of such situations with
flying colors. there are some odd situations that do come up, but when you
hit one of those, the newsgroups are always here... ;)


Chris said:
Thanks Tina, that does help me a great deal. Thanks for taking the time
helping me.
--

Chris


tina said:
you're welcome :)

btw, Chris, one way to help you figure out the placement of quotes is to
start by hard-coding the values, as

[Location] = something And [PSAffiliatedWith] = something else

the entire criteria expression is a string, so enclose it in double quotes,
as

"[Location] = something And [PSAffiliatedWith] = something else"

your values are text data type, so enclose them in single quotes, as

"[Location] = 'something' And [PSAffiliatedWith] = 'something else'"

since the values will be pulled from fields, rather than hard-coded, they
must be *outside* the string, while the single quotes must remain *inside*
the string, as

"[Location] = '" something "' And [PSAffiliatedWith] = '" something else "'"

now you have a series of little strings that must be connected
(concatenated), as

"[Location] = '" & something _
& "' And [PSAffiliatedWith] = '" _
& something else & "'"

<putting the line-break character ( _ ) in just makes sure that you can see
how the string fits together in this post, since a too-long line will
automatically wrap and that can be confusing.>

now that the strings are concatenated, just replace the hard-coded values
with the field references, as

"[Location] = '" & Me!cboLocation _
& "' And [PSAffiliatedWith] = '" _
& Me!MasterPS & "'"

hth


Chris said:
Did the trick. Thanks so much.
--
Thanks for your help,
Chris


:

try

stLinkCriteria = "[Location] = '" & Me![cboLocation] & _
"' And [PSAffiliatedWith] = '" & Me![MasterPS] & "'"

hth


I have a client form where I call via a button a second form showing
personnel at the client's location. Presently, I link via the client's
location and this works fine.

However, I have personnel "affiliated" with other personnel and only
desire
to show those affiliated and in that location.

I know I can add a second criteria, can't seem to get it right!
Can
ya
help? I have tried:

stLinkCriteria = "[Location]=" & "'" & Me![cboLocation] & "'" And
"[PSAffiliatedWith]=" & Me![MasterPS] & "'"

All fields are text boxes.

From the client's form:
cboLocation
MasterPS

From the called location form:
Location
PSAffiliatedWith

I got very confused with the single and double quotes.
 
Top