I have a table in a database named "tblstudentnumber" it has the following columns:

stud_id
stud_fname
stud_lname
stud_address
stud_age
stud_course

i need to have a data report using data environment that can sort all students with the age(a user input) of let say "16".

i have a form, it has a textbox named "txtage", i have a button "search" and a button "print". if i entered 16 in the textbox and if i clicked "print" it will print all data in my table with the age of 16, if i input 17 it will print all data in my table with the age of 17

what is the right sql in the properties of the data environment??

thanks in advance...

I have a table in a database named "tblstudentnumber" it has the following columns:

stud_id
stud_fname
stud_lname
stud_address
stud_age
stud_course

i need to have a data report using data environment that can sort all students with the age(a user input) of let say "16".

i have a form, it has a textbox named "txtage", i have a button "search" and a button "print". if i entered 16 in the textbox and if i clicked "print" it will print all data in my table with the age of 16, if i input 17 it will print all data in my table with the age of 17

what is the right sql in the properties of the data environment??

thanks in advance...

Do you have the table in MS access or a SQL server. You could look at the table in access and use the wizard that can build the SQL using the table / fields.
this is what I would use
"SELECT stud_id, stud_fname, stud_lname, stud_address, stud_age, stud_course FROM tblstudentnumber WHERE stud_age = 16;"
this will only work if stud_age is a number and not text.

Hope this helps
Regards
MattMan

u can try this

select * from tblstudentnumber Where stud_age = text1.text

in parameters tab you need to adjust this
name = pram1
data type = advarwchar
host data type = string (vt_bstr)
in print button write this

Load DataEnvironment1
      With DataEnvironment1
      If .rsCommand1.State <> 0 Then .rsCommand1.Close
      .Command1 text1.Text
      End With
      datareport1.Show
This article has been dead for over six months. Start a new discussion instead.