Hi I've tried to find an answer to this but having no luck.
I have a form that has two combo boxes the first box looks up the year from the project table and the second box the project number. I want to open the project details that correspondes to these two input values within the combo boxes by pressing a command box.
I've tried the following but just get a syntax error:
Private Sub cmdOpenJobDetails_Click()
On Error GoTo Err_cmdOpenJobDetails_Click
Dim strDocName As String
Dim strYear As String
Dim strJobno As String
Dim strFilter As String
strYear = Me.cmbYear.Value
strJobno = Me.cmbJobno.Value
strFilter = "Select [tblProjects].[intprojectyear], [tblProjects.[intprojectjobno] FROM [tblProjects]" & _
"WHERE [intprojectyear] = & strYear And [intprojectjobno] & strJobno"
strDocName = "frmProjectDetails"
DoCmd.OpenForm strDocName, , , strFilter
Exit_cmdOpenJobDetails_Click:
Exit Sub
Err_cmdOpenJobDetails_Click:
MsgBox Err.Description
Resume Exit_cmdOpenJobDetails_Click
End Sub
I have a form that has two combo boxes the first box looks up the year from the project table and the second box the project number. I want to open the project details that correspondes to these two input values within the combo boxes by pressing a command box.
I've tried the following but just get a syntax error:
Private Sub cmdOpenJobDetails_Click()
On Error GoTo Err_cmdOpenJobDetails_Click
Dim strDocName As String
Dim strYear As String
Dim strJobno As String
Dim strFilter As String
strYear = Me.cmbYear.Value
strJobno = Me.cmbJobno.Value
strFilter = "Select [tblProjects].[intprojectyear], [tblProjects.[intprojectjobno] FROM [tblProjects]" & _
"WHERE [intprojectyear] = & strYear And [intprojectjobno] & strJobno"
strDocName = "frmProjectDetails"
DoCmd.OpenForm strDocName, , , strFilter
Exit_cmdOpenJobDetails_Click:
Exit Sub
Err_cmdOpenJobDetails_Click:
MsgBox Err.Description
Resume Exit_cmdOpenJobDetails_Click
End Sub