views:

528

answers:

1

HI

I have a form with a few buttons. Each button runs a few lines of code.the code have queries also in them like "select * from table where number =6"

now if i want to give the number as a input in the form, how do i go about it.

+3  A: 
  1. Add an unbound text control close to your button.
  2. Update your button code to generate the query string as :

    "SELECT * FROM myTable WHERE myNumber =" & me.controls("myControlName").value

  3. You might feel the need to make sure that the "myControlName" control allows only numbers/do not accept null, or treat all cases in your procedure


myQuery = "SELECT * FROM myTable"
If Isnull(me.controls("myControlName").value) then
Else
    If isnumeric(me.controls("myControlName").value) then 
        myQuery = myQuery & " WHERE myNumber =" & me.controls("myControlName").value     
    Else 
        msgBox me.controls("myControlName").value & " is not accepted" 
        Exit function 
    Endif
Endif
Philippe Grondier