Open form on two combo box values

GE160

New member
Local time
Today, 16:59
Joined
Feb 22, 2005
Messages
2
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
 
Try this (I'm assuming the criteria are for Integer fields):

strFilter = "intprojectyear = " & strYear & " And [intprojectjobno] = " & strJobno
 
Sorry its taken awhile to reply but i've just tried your suggestion and unfortunately it didn't work until i did the following:

strFilter = "[tblProjects].[intprojectyear] = " & strYear & " And [tblProjects].[intprojectjobno] = " & strJobno

Now it works a treat. Thank you so much for pointing me in the right direction and taking the time to reply......very much appreciated.
 

Users who are viewing this thread

Back
Top Bottom