stLinkCriteria, parameter prompt and seek 2 fields

  • Thread starter Thread starter Jen
  • Start date Start date
J

Jen

On a form I have this button "Who called" that is supposed to filter my
"phonebook form" so, that one could check, by clicking the "Who called"
button and filling in the number in a parameter prompt, the person who was
calling.

I pass the buttons stLinkCriteria like this (phonenumber still hardcoded as
1234567):

stLinkCriteria = "[telefon]or[gsm]=" & "'" & "1234567" & "'"

As you can see there are two fields from where the phonenumber is to be
filtered; "telefon" (=phone) and "gsm". This works if I only seek the number
from one field, but when I try seeking from these two fields I run inte
problems. tried "Or" as in the example but this won't work.

Jen
 
You need to seperate the two fields. What you are really
saying (to the computer) is: Find records where

[telefon] = '1234567' OR [gsm] = '1234567'


Try it this way. (It should be on one line.)

stLinkCriteria = "[telefon] = '" & "1234567" & "' OR [gsm]
= '" & "1234567" & "'"

HTH

Steve
 
Thanks Steve, that worked. Now if I only could get the parameter prompt to
ask for the number..

Tried stLinkCriteria = "[telefon] = '" & [Ange nummer] & "' OR [gsm] = '" &
[Ange nummer] & "'" and various different approaches, but I'm stuck again
(one of those days).

Jen.

SteveS said:
You need to seperate the two fields. What you are really
saying (to the computer) is: Find records where

[telefon] = '1234567' OR [gsm] = '1234567'


Try it this way. (It should be on one line.)

stLinkCriteria = "[telefon] = '" & "1234567" & "' OR [gsm]
= '" & "1234567" & "'"

HTH

Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)

-----Original Message-----
On a form I have this button "Who called" that is supposed to filter my
"phonebook form" so, that one could check, by clicking the "Who called"
button and filling in the number in a parameter prompt, the person who was
calling.

I pass the buttons stLinkCriteria like this (phonenumber still hardcoded as
1234567):

stLinkCriteria = "[telefon]or[gsm]=" & "'" & "1234567" & "'"

As you can see there are two fields from where the phonenumber is to be
filtered; "telefon" (=phone) and "gsm". This works if I only seek the number
from one field, but when I try seeking from these two fields I run inte
problems. tried "Or" as in the example but this won't work.

Jen


.
 
Put an unbound TextBox "txtSearchFor" so that the user can enter the String
to search for and use:

stLinkCriteria = "[telefon] = '" & Me.txtSearchFor & _
"' OR [gsm] = '" & Me.txtSearchFor & "'"
 
Thanks again Van T. Dinh. Works ok except of that the Cancel button works
just like the Ok button, but I can live with that (grateful if you tell me
why though). Thanks again. Jen

Van T. Dinh said:
Something like:

Dim strSearchFor As String

strSearchFor = Application.InputBox("Enter a number")

stLinkCriteria = "[telefon] = '" & strSearchFor & _
"' OR [gsm] = '" & strSearchFor & "'"

Check Access VB Help on InputBox() function for other arguments.

--
HTH
Van T. Dinh
MVP (Access)



Jen said:
Thank you Van T. Dinh for your answer. I know I could get the value from an
unbound textbox. However I would prefer a Parameter prompt for this because
of the layout of the form. Is it possible?

Jen
 
Cancel on the InputBox simply returns an empty String. If you want, you can
trap this using an If statement in your code and do different action if an
empty String is returned.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top