Hi,
Can someone help me here, I have never used Access and I am working on my BA stuff that needs a sample mock up report for the business, where I need a form which gets data as a result of SQL query I created. But now I need to filter the data using 2 text boxes that I have on the form (Startdate and enddate). i.e. when the user enters the date in the text boxes and clicks the button next to it, I need my code to (whatever that is...I dont know) should magically get these dates into the SQL query and fetch data and populate the data in the boxes I have created in the form.
Form Name- PriceForm
Button- Cmd_Enter
TxtBoxes- txt_startdate and txt_enddate
Display text boxes- txt_1...to txt_20 (which displays the data fetched)
SQL Query- select * from FinalList where sortorder=1 and rundate between startdate and enddate
Code that I created-
Private Sub cmdEnter_Click()
Dim qdf As QueryDef
Dim sttd as date
Dim eddt as date
Dim obj As AccessObject As Object
Set qdf = CurrentDb.QueryDefs("FinalList")
Set stdt = TxtBx_EnterStartDate.Text
Set eddt = TxtBx_EnterEndDate.Text
Dim rs As Recordset
'-----PROCESSING ROW 1-------------------------------------------------------------
RunSQL = "select * from FinalList where sortorder=1 and rundate between stdt and eddt"
Set rs = qdf.OpenRecordset(RunSQL)
If Not rs.EOF Then
If rs.RecordCount = 1 Then
Me.Txtbx_1CT.Value = rs![row_count]
Me.Txtbx_1RCT.Value = rs![row_count]
Me.Txtbx_1ECT.Value = rs![except_count]
End If
rs.MoveNext
If rs.RecordCount = 2 Then
Me.TxtBx_1CT.Value = rs![row_count]
Me.TxtBx_1RCT.Value = rs![row_count]
Me.TxtBx_1ECT.Value = rs![except_count]
End If
End If
Set rs = Nothing
End Sub
Please help...................
Can someone help me here, I have never used Access and I am working on my BA stuff that needs a sample mock up report for the business, where I need a form which gets data as a result of SQL query I created. But now I need to filter the data using 2 text boxes that I have on the form (Startdate and enddate). i.e. when the user enters the date in the text boxes and clicks the button next to it, I need my code to (whatever that is...I dont know) should magically get these dates into the SQL query and fetch data and populate the data in the boxes I have created in the form.
Form Name- PriceForm
Button- Cmd_Enter
TxtBoxes- txt_startdate and txt_enddate
Display text boxes- txt_1...to txt_20 (which displays the data fetched)
SQL Query- select * from FinalList where sortorder=1 and rundate between startdate and enddate
Code that I created-
Private Sub cmdEnter_Click()
Dim qdf As QueryDef
Dim sttd as date
Dim eddt as date
Dim obj As AccessObject As Object
Set qdf = CurrentDb.QueryDefs("FinalList")
Set stdt = TxtBx_EnterStartDate.Text
Set eddt = TxtBx_EnterEndDate.Text
Dim rs As Recordset
'-----PROCESSING ROW 1-------------------------------------------------------------
RunSQL = "select * from FinalList where sortorder=1 and rundate between stdt and eddt"
Set rs = qdf.OpenRecordset(RunSQL)
If Not rs.EOF Then
If rs.RecordCount = 1 Then
Me.Txtbx_1CT.Value = rs![row_count]
Me.Txtbx_1RCT.Value = rs![row_count]
Me.Txtbx_1ECT.Value = rs![except_count]
End If
rs.MoveNext
If rs.RecordCount = 2 Then
Me.TxtBx_1CT.Value = rs![row_count]
Me.TxtBx_1RCT.Value = rs![row_count]
Me.TxtBx_1ECT.Value = rs![except_count]
End If
End If
Set rs = Nothing
End Sub
Please help...................