Where Clause

T

Tamer

Hi all,
I have a text box and a cmd button in a from. When I enter
few letters in the text box and click on the cmd button, I
want to open another form that has a list box and I want
the clients names begining with the few letters I typed in
the text box to be generated or selected in the list box.

I used the following syntax, but it seems I'm missing
something. Please help

Dim str as String
str = Left([textbox4],4)
DoCmd.OpenForm "FormName", acNormal, , "[client Name]
Like " & str & "*"

Thanks,
Tamer Seoud
 
C

Chris Large

Hi

Where clause should be:-

"[client Name] Like """ & str & "*"""


uses double quotes "" within quotes so that final string
has quotes around the str*.

hth

Chris
 
T

Tamer

Thanks for your response. I tried your suggestion, but it
didn't work, any ideas? I used the following syntax:

Dim str As String
str = Left([ChildName], 4)
DoCmd.OpenForm "frm_UCRsChildrenNames",
acNormal, , "[lst_ChildName] Like """ & _
str & "*"""
-----Original Message-----
Hi

Where clause should be:-

"[client Name] Like """ & str & "*"""


uses double quotes "" within quotes so that final string
has quotes around the str*.

hth

Chris
-----Original Message-----
Hi all,
I have a text box and a cmd button in a from. When I enter
few letters in the text box and click on the cmd button, I
want to open another form that has a list box and I want
the clients names begining with the few letters I typed in
the text box to be generated or selected in the list box.

I used the following syntax, but it seems I'm missing
something. Please help

Dim str as String
str = Left([textbox4],4)
DoCmd.OpenForm "FormName", acNormal, , "[client Name]
Like " & str & "*"

Thanks,
Tamer Seoud

.
.
 
C

Chris Large

Hi

The code you used will work as long as your
field/formnames are correct

DoCmd.OpenForm "FormName", acNormal, , "[FieldName]
Like """ & Left([TextBoxName], 4) & "*"""

Where FormName is the Form you are opening
FieldName is a text field in the Record Source of FormName
TextBoxName is on the 'Search Form'

hth

Chris

-----Original Message-----
Thanks for your response. I tried your suggestion, but it
didn't work, any ideas? I used the following syntax:

Dim str As String
str = Left([ChildName], 4)
DoCmd.OpenForm "frm_UCRsChildrenNames",
acNormal, , "[lst_ChildName] Like """ & _
str & "*"""
-----Original Message-----
Hi

Where clause should be:-

"[client Name] Like """ & str & "*"""


uses double quotes "" within quotes so that final string
has quotes around the str*.

hth

Chris
-----Original Message-----
Hi all,
I have a text box and a cmd button in a from. When I enter
few letters in the text box and click on the cmd
button,
I
want to open another form that has a list box and I want
the clients names begining with the few letters I typed in
the text box to be generated or selected in the list box.

I used the following syntax, but it seems I'm missing
something. Please help

Dim str as String
str = Left([textbox4],4)
DoCmd.OpenForm "FormName", acNormal, , "[client Name]
Like " & str & "*"

Thanks,
Tamer Seoud

.
.
.
 
T

Tamer

In my case, FieldName is not a TextBox control, it's a
list box tied to an SQL statement that generates the list
box from a query with clients names. Will that make a
difference? I copy the same code you sent me and make sure
the fields and forms names are correct, but it's not
working.
Please advise. Thanks.
-----Original Message-----
Hi

The code you used will work as long as your
field/formnames are correct

DoCmd.OpenForm "FormName", acNormal, , "[FieldName]
Like """ & Left([TextBoxName], 4) & "*"""

Where FormName is the Form you are opening
FieldName is a text field in the Record Source of FormName
TextBoxName is on the 'Search Form'

hth

Chris

-----Original Message-----
Thanks for your response. I tried your suggestion, but it
didn't work, any ideas? I used the following syntax:

Dim str As String
str = Left([ChildName], 4)
DoCmd.OpenForm "frm_UCRsChildrenNames",
acNormal, , "[lst_ChildName] Like """ & _
str & "*"""
-----Original Message-----
Hi

Where clause should be:-

"[client Name] Like """ & str & "*"""


uses double quotes "" within quotes so that final string
has quotes around the str*.

hth

Chris

-----Original Message-----
Hi all,
I have a text box and a cmd button in a from. When I
enter
few letters in the text box and click on the cmd button,
I
want to open another form that has a list box and I want
the clients names begining with the few letters I typed
in
the text box to be generated or selected in the list box.

I used the following syntax, but it seems I'm missing
something. Please help

Dim str as String
str = Left([textbox4],4)
DoCmd.OpenForm "FormName", acNormal, , "[client Name]
Like " & str & "*"

Thanks,
Tamer Seoud

.

.
.
.
 

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

Similar Threads


Top