(Msg. 1) Posted: Mon Oct 06, 2008 6:55 pm
Post subject: how to have access recognize data type? HELP Archived from groups: microsoft>public>access (more info?)
I have a text box for search. I like to be able to search Account number
(number )or Customer Name (string)
When I click search button I like access to be able to get the sql statement:
For example :
If text box value is number than go to SQLA
if text box value is string than go to SQLB
Can anyone help me ?
Thanks in advance for any help....
Ges
--
Ges Khu
Geskhu.TakeThisOut@yahoo.com
Access Beginner
(Msg. 2) Posted: Mon Oct 06, 2008 6:55 pm
Post subject: Re: how to have access recognize data type? HELP [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
"ges" <[email snipped]> wrote in message news:8b45c2daffde6@uwe...
>I have a text box for search. I like to be able to search Account number
> (number )or Customer Name (string)
>
> When I click search button I like access to be able to get the sql
> statement:
> For example :
> If text box value is number than go to SQLA
> if text box value is string than go to SQLB
>
> Can anyone help me ?
>
> Thanks in advance for any help....
>
> Ges
>
> --
> Ges Khu
(Note: I don't recommend posting your e-mail address in a public newsgroup.
It's a good way to get yourself buried in spam.)
You should be able to use code along these lines:
If IsNull(Me!txtSearchFor) Then
MsgBox "Enter something in the search box, please."
ElseIf Me!txtSearchFor Like "*[!0-9]*" Then
' It's text -- use SQL for string value ...
Else
' It's numeric -- use SQL for number value ...
End If
(Msg. 3) Posted: Mon Oct 06, 2008 6:55 pm
Post subject: Re: how to have access recognize data type? HELP [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
"ges via AccessMonster.com" wrote in message news:8b465111cb8b1@uwe...
> Dirk,
> Thanks for the advice and the code, THANK YOU.
> If you don't mind I just have one more question:
>
> I like to have the text box value using LIKE "Psych%"
> WHERE (((tblAccounts.a_FileType)='Arden') AND ((tblAccounts.a_BillName)
> Like
> "Psych%"))
>
> How do I put it in text box?
>
> I try as follow but give me an error:
> WHERE tblAccounts.a-BillName LIKE " & """"% & textbox& """" & "
Do you want all searches of this type to use the wild-cards, so you're
looking for any record that contains the value in the text box? If so,
you're almost there, but you've got quoting problems. Try this
"WHERE tblAccounts.a-BillName LIKE ""%" & textbox & "%"""
I'm assuming you're building this SQL string in code, so we need to
double-up the quotes that go inside the SQL literal. Or you could avoid
that confusing notation by using Chr(34) instead:
All times are: Eastern Time (US & Canada) (change)
Page 1 of 1
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum