T
tmdrake
I have use this great forum so many times to help with different issues I
have had. I am hoping the same will happen this time.
Here we go:
I have created a form (recordsource [tblProject Staffing Resources]. On this
form there are 4 bound comboxes each linked to an individual table (exp.
Combox Box 1 = ProjectID linked to table ProjectID(2)) the same for the other
three DisciplineName, SectionNumber, and LastName. Each having a table
representing that field.
There is also a command button to click when any one or any combination of
the comboxes is chosen. So far this works. The code for this button is:
Private Sub Select_Click()
Dim strSQL As String
strSQL = "SELECT [tblProject Staffing Resources].ProjectID, " _
& "[tblProject Staffing Resources].DisciplineName, " _
& "[tblProject Staffing Resources].SectionNumber, " _
& "[tblProject Staffing Resources].LastName, " _
& "[tblProject Staffing Resources].[FirstName], " _
& "[tblProject Staffing Resources].[Discipline Lead], " _
& "[tblProject Staffing Resources].[Est Project Start Date], " _
& "[tblProject Staffing Resources].[Est Project End Date], " _
& "[tblProject Staffing Resources].EmployeeID " _
& "FROM [tblProject Staffing Resources] 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.Project_Staffing_Resources_subform.Form.RecordSource = strSQL
End Sub
Secondly, on this form is a subform with 8 text boxes (the recordsource
=SELECT [tblProject Staffing Resources].ProjectID, [tblProject Staffing
Resources].DisciplineName, [tblProject Staffing Resources].SectionNumber,
[tblProject Staffing Resources].LastName, [tblProject Staffing
Resources].FirstName, [tblProject Staffing Resources].[Discipline Lead],
[tblProject Staffing Resources].[Est Project Start Date], [tblProject
Staffing Resources].[Est Project End Date], [tblProject Staffing
Resources].EmployeeID FROM [tblProject Staffing Resources] WHERE True And
[DisciplineName]='Thermal' And [SectionNumber]=4470 ; based on the
selection made by one or more of the comboxes the results appear in a
Datasheet view on the subform. This also works fine.
The Problem: when all the comboxes are cleared (trying to write a code for a
command button that will clear any selections made and will allow another
selection to be made.) and you click on the subform the data from the first
line of the results disappear and that information is deleted from the table.
How do I fix this and how do I write the code to clear all selections made
in the combo box and allow another selection to be made and the results
showup on the subform (datasheet view)
Anyones help will be greatly appreciated.
Thanks
have had. I am hoping the same will happen this time.
Here we go:
I have created a form (recordsource [tblProject Staffing Resources]. On this
form there are 4 bound comboxes each linked to an individual table (exp.
Combox Box 1 = ProjectID linked to table ProjectID(2)) the same for the other
three DisciplineName, SectionNumber, and LastName. Each having a table
representing that field.
There is also a command button to click when any one or any combination of
the comboxes is chosen. So far this works. The code for this button is:
Private Sub Select_Click()
Dim strSQL As String
strSQL = "SELECT [tblProject Staffing Resources].ProjectID, " _
& "[tblProject Staffing Resources].DisciplineName, " _
& "[tblProject Staffing Resources].SectionNumber, " _
& "[tblProject Staffing Resources].LastName, " _
& "[tblProject Staffing Resources].[FirstName], " _
& "[tblProject Staffing Resources].[Discipline Lead], " _
& "[tblProject Staffing Resources].[Est Project Start Date], " _
& "[tblProject Staffing Resources].[Est Project End Date], " _
& "[tblProject Staffing Resources].EmployeeID " _
& "FROM [tblProject Staffing Resources] 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.Project_Staffing_Resources_subform.Form.RecordSource = strSQL
End Sub
Secondly, on this form is a subform with 8 text boxes (the recordsource
=SELECT [tblProject Staffing Resources].ProjectID, [tblProject Staffing
Resources].DisciplineName, [tblProject Staffing Resources].SectionNumber,
[tblProject Staffing Resources].LastName, [tblProject Staffing
Resources].FirstName, [tblProject Staffing Resources].[Discipline Lead],
[tblProject Staffing Resources].[Est Project Start Date], [tblProject
Staffing Resources].[Est Project End Date], [tblProject Staffing
Resources].EmployeeID FROM [tblProject Staffing Resources] WHERE True And
[DisciplineName]='Thermal' And [SectionNumber]=4470 ; based on the
selection made by one or more of the comboxes the results appear in a
Datasheet view on the subform. This also works fine.
The Problem: when all the comboxes are cleared (trying to write a code for a
command button that will clear any selections made and will allow another
selection to be made.) and you click on the subform the data from the first
line of the results disappear and that information is deleted from the table.
How do I fix this and how do I write the code to clear all selections made
in the combo box and allow another selection to be made and the results
showup on the subform (datasheet view)
Anyones help will be greatly appreciated.
Thanks