Sam,
Place the searchbutton in the formheader (if there's no header set a header
yourself).
Set the recordsource of your form to your query "qGeneric".
Drag all of the fields from that query to your form.
Now in the code you just have to make a minor change
Private Sub Search_Click()
Dim qdf As Object, StrSql As String, dbs As Object
Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef("qGeneric")
StrSql = "PROCEDURE CategoryList; " _
& "SELECT [Stu_ID],[HeightIn],[WeightLB],[Delta]" _
& " FROM Student_Table" _
& " WHERE " _
& “Student_ID = “ & Me.StudId.Value _
& " AND " _
& “Height BETWEEN “ & Me.Height1.Value & “ AND “ &
Me.Height2.Value _
& " AND " _
& “Weight BETWEEN “ & Me.Weight1.Value & “ AND “ &
Me.Weight2.Value _
& “Delta BETWEEN “ & Me.Delta1.Value & “ AND “ &
Me.Delta2.Value
dbs.QueryDefs("qGeneric").SQL = StrSql
me.requery
Set qdf = Nothing
Set dbs = Nothing
End Sub
You don't have to delete the query because it will be overwritten everytime.
hth
--
Maurice Ausum
sam said:
Hi Maurice,
Here is the search code:
Private Sub Search_Click()
Dim qdf As Object, StrSql As String, dbs As Object
Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef("qGeneric")
StrSql = "PROCEDURE CategoryList; " _
& "SELECT [Stu_ID],[HeightIn],[WeightLB],[Delta]" _
& " FROM Student_Table" _
& " WHERE " _
& “Student_ID = “ & Me.StudId.Value _
& " AND " _
& “Height BETWEEN “ & Me.Height1.Value & “ AND “ &
Me.Height2.Value _
& " AND " _
& “Weight BETWEEN “ & Me.Weight1.Value & “ AND “ &
Me.Weight2.Value _
& “Delta BETWEEN “ & Me.Delta1.Value & “ AND “ &
Me.Delta2.Value
dbs.QueryDefs("qGeneric").SQL = StrSql
DoCmd.OpenQuery "qGeneric"
dbs.QueryDefs.Delete "qGeneric"
Set qdf = Nothing
Set dbs = Nothing
End Sub
:
First you need to tell us how you added the search functionality. Why does it
go to a seperate tab? You could place the searchbutton in a form header and
present the results in the detailsection of the form. But then again we need
to know the current situation.
Paste your search code here so we can take a look at it.
--
Maurice Ausum
:
Hi All,
I have designed a form with search button to search from the database. how
can I make the output display below the search button?
Right now the results are displayed in a new tab, But I want to display the
results in the same window below the search criteria.
How can I get this to work?
Thanks in advance