I have a form with a combo box. I have a cmd button on the form that is supposed to use whatever I have selected in the combo box for a string value in some SQL code. However, it's coming up as an empty string but I can't figure out why. I done this hundreds of times before and it worked fine. Please help.
Private Sub cmdFindMinNecessary_Click()
Dim db As Database
Dim rs As Recordset
Dim strJobTitle As String
Dim SQL As String
Dim strEEID As String
strJobTitle = Forms![MinimumNecessary]![cmbJobTitle]
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT All_Personnel.Active, All_Personnel.LastName, All_Personnel.FirstName, All_Personnel.EEID, All_Personnel.JobTitle, All_Personnel.Department, All_Personnel.RollUp, All_Personnel.Supervisor, All_Personnel.PersonnelType FROM All_Personnel WHERE All_Personnel.JobTitle = "" & strJobTitle & "";")
Do Until rs.EOF
strEEID = rs![EEID]
strJobTitle = Forms![MinimumNecessary]![cmbJobTitle]
SQL = "INSERT INTO y_tmpMinNecCol( DataSource, AccessLevel, AccessCapability, Status, AccountExpiration, EEID)" & _
"SELECT tmpCollector.DataSource, tmpCollector.AccessLevel, tmpCollector.AccessCapability, tmpCollector.Status, tmpCollector.AccountExpiration, tmpCollector.EEID FROM tmpCollector WHERE tmpCollector.EEID = " & strEEID & ";"
db.Execute SQL
rs.MoveNext
Loop
MsgBox "A table has been created."
End Sub
Private Sub cmdFindMinNecessary_Click()
Dim db As Database
Dim rs As Recordset
Dim strJobTitle As String
Dim SQL As String
Dim strEEID As String
strJobTitle = Forms![MinimumNecessary]![cmbJobTitle]
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT All_Personnel.Active, All_Personnel.LastName, All_Personnel.FirstName, All_Personnel.EEID, All_Personnel.JobTitle, All_Personnel.Department, All_Personnel.RollUp, All_Personnel.Supervisor, All_Personnel.PersonnelType FROM All_Personnel WHERE All_Personnel.JobTitle = "" & strJobTitle & "";")
Do Until rs.EOF
strEEID = rs![EEID]
strJobTitle = Forms![MinimumNecessary]![cmbJobTitle]
SQL = "INSERT INTO y_tmpMinNecCol( DataSource, AccessLevel, AccessCapability, Status, AccountExpiration, EEID)" & _
"SELECT tmpCollector.DataSource, tmpCollector.AccessLevel, tmpCollector.AccessCapability, tmpCollector.Status, tmpCollector.AccountExpiration, tmpCollector.EEID FROM tmpCollector WHERE tmpCollector.EEID = " & strEEID & ";"
db.Execute SQL
rs.MoveNext
Loop
MsgBox "A table has been created."
End Sub