Ok I have a series of combo boxes and I want each combo box to display the data depending on whats in the other combo boxes. but I cannot get the combo box to populate any data I get no errors and even when I put a break on the event procedure nothing happens.
Option Compare Database
Dim Fname As String
Dim sname As String
Dim Pay As String
Fname = cboFname.Text
sname = cboSname.Text
Pay = cboPayroll.Text
Private Sub cboPayroll_Click()
If Fname + sname = "" Then
cboPayroll.RowSource = "SELECT UserDetails.Payroll FROM UserDetails;"
ElseIf Fname = Not "" And sname = "" Then
cboPayroll.RowSource = "SELECT UserDetails.Payroll, UserDetails.[First Name] FROM UserDetails WHERE (((UserDetails.[First Name])=" + Fname + ");"
ElseIf sname = Not "" And Fname = "" Then
cboPayroll.RowSource = "SELECT UserDetails.Payroll, UserDetails.Surname FROM UserDetails WHERE (((UserDetails.Surname)=" + sname + ");"
ElseIf sname = Not "" And Fname = Not "" Then
cboPayroll.RowSource = "SELECT UserDetails.[First Name], UserDetails.Surname, UserDetails.Payroll FROM UserDetails WHERE (((UserDetails.[First Name])=" + Fname + " AND ((UserDetails.Surname)=" + sname + ");"
End If
Form.Refresh
cboPayroll.Requery
End Sub
Thats the code hope ppl understand it ok and can tell me why it aint doing what I thought it should
Option Compare Database
Dim Fname As String
Dim sname As String
Dim Pay As String
Fname = cboFname.Text
sname = cboSname.Text
Pay = cboPayroll.Text
Private Sub cboPayroll_Click()
If Fname + sname = "" Then
cboPayroll.RowSource = "SELECT UserDetails.Payroll FROM UserDetails;"
ElseIf Fname = Not "" And sname = "" Then
cboPayroll.RowSource = "SELECT UserDetails.Payroll, UserDetails.[First Name] FROM UserDetails WHERE (((UserDetails.[First Name])=" + Fname + ");"
ElseIf sname = Not "" And Fname = "" Then
cboPayroll.RowSource = "SELECT UserDetails.Payroll, UserDetails.Surname FROM UserDetails WHERE (((UserDetails.Surname)=" + sname + ");"
ElseIf sname = Not "" And Fname = Not "" Then
cboPayroll.RowSource = "SELECT UserDetails.[First Name], UserDetails.Surname, UserDetails.Payroll FROM UserDetails WHERE (((UserDetails.[First Name])=" + Fname + " AND ((UserDetails.Surname)=" + sname + ");"
End If
Form.Refresh
cboPayroll.Requery
End Sub
Thats the code hope ppl understand it ok and can tell me why it aint doing what I thought it should