Here is the code, tables, query, and relationship
#####Code that returns the data to show the query works #####
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
stDocName = "qryFindEmpByJobType"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
#####Code behind the button usaing VBA and DAO#####
Private Sub cmdFindEmpByJobType_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
'Get handle to database
Set dbs = CurrentDb
'Get handle to query results
strQry = "qryFindEmpByJobType"
Set rst = dbs.OpenRecordset(strQry)
'Display record count of results
rst.MoveLast
MsgBox rst.RecordCount
End Sub
#####SQL code for Query#####
SELECT EmpDetails.EmpID, EmpDetails.JobTypeID, EmpDetails.Name
FROM EmpDetails
WHERE (((EmpDetails.JobTypeID)=[Forms]![frmFindEmpByJobType]![comboJobTypeSelected]));
#####JobType Table#####
#####Filed Name - Data Type #####
JobTypeID - AutoNumber (Primary Key)
JobTypeDescription - Text
#####EmpDetails Table#####
#####Filed Name - Data Type #####
EmpID - AutoNumber (Primary Key)
JobTypeID Number (Linked to JobType.JobTypeID using Lookup Wizard.
Name - Text
#####Relationships#####
One to Many relationship as
JobType.JobTypeID to EmpDetails.JobTypeID