Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using operators with inputbox query

Status
Not open for further replies.

vaughn9

Technical User
Sep 23, 2001
183
I am using the code below with msflexgrid to display the age of a customer. It works fine, but how can I use an operator < or > or <> in the message box. I know I can do it in an an sql statement in a text box and then use the command button to say data1.record source = text1, but I want to use the input box and still be able to say less than or more than a particular age or between two ages

Can someone tell me how I can get that done using the input box

my present code

Dim mystring As String
mystring = InputBox("Enter Customer Age Please name", "Client Name")

Data1.RecordSource = "select Surname, Age, Salary from datatable where Age = '" & mystring & "'"

Data1.Refresh



MSFlexGrid1.Refresh
 
Just add <= or >=
If age is a numeric value in the table then add cint() to convert the string to numbers and remove the "'" marks

Data1.RecordSource = "select Surname, Age, Salary from datatable where Age >= "'" & mystring & "'"

Data1.RecordSource = "select Surname, Age, Salary from datatable where Age <= " & cint(mystring)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top