finding records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I had a macro for searching records placed on "OnOpen" event of my form
"ContactPersons".
But this was inconvenient, so i wanted to include the code of that macro
into the script of the button on MAIN form which opens the form
"ContactPersons".

The script below DOES open the form, DOES show the pop-up window with the
words "Enter the Person's Name", but it DOES NOT return any results - only
empy form.

What can be wrong here??? PLEASE HELP!

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ContactPersons"

stLinkCriteria = "[stContactPersons]![ClientName] Like (' * ' + [Enter
the Person's Name] + ' * ')"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Hi Lana,

Try using ampersands instead of +, and remove the extra spaces between the
wildcard and the quotes:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ContactPersons"

stLinkCriteria = "[stContactPersons]![ClientName] Like ('*' & [Enter
the Person's Name] & '*')"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Thank you so much Susan!

It was the extra spaces. After i removed them - everything worked fine!!!

Lana


SusanV said:
Hi Lana,

Try using ampersands instead of +, and remove the extra spaces between the
wildcard and the quotes:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ContactPersons"

stLinkCriteria = "[stContactPersons]![ClientName] Like ('*' & [Enter
the Person's Name] & '*')"
DoCmd.OpenForm stDocName, , , stLinkCriteria


--
hth,
SusanV


Lana said:
Hi all,

I had a macro for searching records placed on "OnOpen" event of my form
"ContactPersons".
But this was inconvenient, so i wanted to include the code of that macro
into the script of the button on MAIN form which opens the form
"ContactPersons".

The script below DOES open the form, DOES show the pop-up window with the
words "Enter the Person's Name", but it DOES NOT return any results - only
empy form.

What can be wrong here??? PLEASE HELP!

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ContactPersons"

stLinkCriteria = "[stContactPersons]![ClientName] Like (' * ' + [Enter
the Person's Name] + ' * ')"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Glad to help anytime!
;-)

Lana said:
Thank you so much Susan!

It was the extra spaces. After i removed them - everything worked fine!!!

Lana


SusanV said:
Hi Lana,

Try using ampersands instead of +, and remove the extra spaces between
the
wildcard and the quotes:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ContactPersons"

stLinkCriteria = "[stContactPersons]![ClientName] Like ('*' & [Enter
the Person's Name] & '*')"
DoCmd.OpenForm stDocName, , , stLinkCriteria


--
hth,
SusanV


Lana said:
Hi all,

I had a macro for searching records placed on "OnOpen" event of my form
"ContactPersons".
But this was inconvenient, so i wanted to include the code of that
macro
into the script of the button on MAIN form which opens the form
"ContactPersons".

The script below DOES open the form, DOES show the pop-up window with
the
words "Enter the Person's Name", but it DOES NOT return any results -
only
empy form.

What can be wrong here??? PLEASE HELP!

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ContactPersons"

stLinkCriteria = "[stContactPersons]![ClientName] Like (' * ' +
[Enter
the Person's Name] + ' * ')"
DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Back
Top