finding records

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
 
S

SusanV

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
 
G

Guest

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
 
S

SusanV

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
 

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