Hi guys
I have table with various fields named as ename,dname,Mon,Tue,Wed,Thu,Fri,Sat,Sun.
I want to pop up those enames in the combobox whose corresponding day value is not equal to 0. I am writing the following code but I have a doubt in using variable name(b) to specify a field name in the table. Please have a look at the code and see how i am using variable b to specify any day which is a field in the table.
Thanks
Aman
I have table with various fields named as ename,dname,Mon,Tue,Wed,Thu,Fri,Sat,Sun.
I want to pop up those enames in the combobox whose corresponding day value is not equal to 0. I am writing the following code but I have a doubt in using variable name(b) to specify a field name in the table. Please have a look at the code and see how i am using variable b to specify any day which is a field in the table.
Code:
Private Sub Combo8_LostFocus()
Text12.Value = ""
Dim strText, strFind As String
Dim a As String
Dim b As String
a = Label14.Caption
If a = "Monday" Then
b = "Mon"
ElseIf a = "Tuesday" Then
b = "Tue"
ElseIf a = "Wednesday" Then
b = "Wed"
ElseIf a = "Thursday" Then
b = "Thu"
ElseIf a = "Friday" Then
b = "Fri"
End If
strFind = "dname='" & Combo8.Value & "'"
' If Len(Trim(strText)) > 0 Then
strFind = strFind & " and [COLOR=red]" & b & " <> 0"
[/COLOR]
strSql = "SELECT ename FROM tbstaff1 Where " & _
strFind & " ORDER BY ename;"
Me.Combo10.RowSource = strSql
End Sub
Thanks
Aman