T
tmdrake
I have created a Main Form with 4 comboxes where the user can select from one
of the comboxes or make mutiple selection from any of the four, then click
the "Select Button"; where the results are displayed on a subform.
This works fine, however I would like to add a combox for "Start Date" and
a combox for "End Date" to the Main Form. Where the user will have to select
a "start date" and a "end date", in combination with a selection from one or
more of the other 4 comboxes then click the "Select Button" for the results
for that date range to appear in the subform.
This is the code I am using to make the selection for the 4 comboxes, what
will I need to add to also include the date boxes?
Private Sub Select_Click()
Dim strSQL As String
strSQL = "SELECT [tblHours_Worked].ProjectID, " _
& "[tblHours_Worked].DisciplineName, " _
& "[tblHours_Worked].SectionNumber, " _
& "[tblHours_Worked].LastName, " _
& "[tblHours_Worked].[FirstName], " _
& "[tblHours_Worked].[SLC Code], " _
& "[tblHours_Worked].[Week Ending], " _
& "[tblHours_Worked].[PHW], " _
& "[tblHours_Worked].[AHW] " _
& "FROM [tblHours_Worked] WHERE True"
If Not IsNull(Me![DisciplineName]) Then
strSQL = strSQL & " AND [DisciplineName] = '" & Me![DisciplineName] & "'"
End If
If Not IsNull(Me![SectionNumber]) Then
strSQL = strSQL & " AND [SectionNumber] = " & Me![SectionNumber] & ""
End If
If Not IsNull(Me![ProjectID]) Then
strSQL = strSQL & " AND [ProjectId] = '" & Me![ProjectID] & "'"
End If
If Not IsNull(Me![LastName]) Then
strSQL = strSQL & " AND [LastName] = '" & Me![LastName] & "'"
End If
Debug.Print strSQL
Me.frmHours_Worked_subform.Form.RecordSource = strSQL
End Sub
Help is greatly appreciated.
of the comboxes or make mutiple selection from any of the four, then click
the "Select Button"; where the results are displayed on a subform.
This works fine, however I would like to add a combox for "Start Date" and
a combox for "End Date" to the Main Form. Where the user will have to select
a "start date" and a "end date", in combination with a selection from one or
more of the other 4 comboxes then click the "Select Button" for the results
for that date range to appear in the subform.
This is the code I am using to make the selection for the 4 comboxes, what
will I need to add to also include the date boxes?
Private Sub Select_Click()
Dim strSQL As String
strSQL = "SELECT [tblHours_Worked].ProjectID, " _
& "[tblHours_Worked].DisciplineName, " _
& "[tblHours_Worked].SectionNumber, " _
& "[tblHours_Worked].LastName, " _
& "[tblHours_Worked].[FirstName], " _
& "[tblHours_Worked].[SLC Code], " _
& "[tblHours_Worked].[Week Ending], " _
& "[tblHours_Worked].[PHW], " _
& "[tblHours_Worked].[AHW] " _
& "FROM [tblHours_Worked] WHERE True"
If Not IsNull(Me![DisciplineName]) Then
strSQL = strSQL & " AND [DisciplineName] = '" & Me![DisciplineName] & "'"
End If
If Not IsNull(Me![SectionNumber]) Then
strSQL = strSQL & " AND [SectionNumber] = " & Me![SectionNumber] & ""
End If
If Not IsNull(Me![ProjectID]) Then
strSQL = strSQL & " AND [ProjectId] = '" & Me![ProjectID] & "'"
End If
If Not IsNull(Me![LastName]) Then
strSQL = strSQL & " AND [LastName] = '" & Me![LastName] & "'"
End If
Debug.Print strSQL
Me.frmHours_Worked_subform.Form.RecordSource = strSQL
End Sub
Help is greatly appreciated.