ADawn
asked on
Add (NONE) to Combo List
Hello,
VB6 (sp5), ADO, Access 97
I want the user to have the option of selecting an item called (No Notification) or (None) if one of the supervisor's names does not appear in the combo box.
' Fill the Supervisor Combo Box
sSqlSupvr = "Select tbl_ApplicationUsers.UserL Name, " _
& "tbl_ApplicationUsers.User FName, " _
& "tbl_ApplicationUsers.User Department " _
& "From tbl_ApplicationUsers " _
& "WHERE(tbl_ApplicationUser s.UserSupe rvisor = True) " _
& "ORDER BY UserLName ASC;"
rst.CursorLocation = adUseClient
rst.Open sSqlSupvr, App_Conn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
strSupvrName = rst("UserLName") & ", " & rst("UserFName")
Me.cboSupvr.AddItem strSupvrName
rst.MoveNext
Loop
Thanks,
-ADawn
VB6 (sp5), ADO, Access 97
I want the user to have the option of selecting an item called (No Notification) or (None) if one of the supervisor's names does not appear in the combo box.
' Fill the Supervisor Combo Box
sSqlSupvr = "Select tbl_ApplicationUsers.UserL
& "tbl_ApplicationUsers.User
& "tbl_ApplicationUsers.User
& "From tbl_ApplicationUsers " _
& "WHERE(tbl_ApplicationUser
& "ORDER BY UserLName ASC;"
rst.CursorLocation = adUseClient
rst.Open sSqlSupvr, App_Conn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
strSupvrName = rst("UserLName") & ", " & rst("UserFName")
Me.cboSupvr.AddItem strSupvrName
rst.MoveNext
Loop
Thanks,
-ADawn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use This code
>> dim blnSupFound as boolean
>> dim strSupNameLookingFor as string
>> 'Set the the supervisor name you are looking for
>> strSupNameLookingFor = "Supervisor1"
' Fill the Supervisor Combo Box
sSqlSupvr = "Select tbl_ApplicationUsers.UserL Name, " _
& "tbl_ApplicationUsers.User FName, " _
& "tbl_ApplicationUsers.User Department " _
& "From tbl_ApplicationUsers " _
& "WHERE(tbl_ApplicationUser s.UserSupe rvisor = True) " _
& "ORDER BY UserLName ASC;"
rst.CursorLocation = adUseClient
rst.Open sSqlSupvr, App_Conn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
strSupvrName = rst("UserLName") & ", " & rst("UserFName")
Me.cboSupvr.AddItem strSupvrName
>> if strSupNameLookingFor = strSupvrName then
>> blnSupFound = True
>> End if
rst.MoveNext
Loop
>> If blnSupFound = False then
>> Me.cboSupvr.AddItem "NONE"
>> End if
>> dim blnSupFound as boolean
>> dim strSupNameLookingFor as string
>> 'Set the the supervisor name you are looking for
>> strSupNameLookingFor = "Supervisor1"
' Fill the Supervisor Combo Box
sSqlSupvr = "Select tbl_ApplicationUsers.UserL
& "tbl_ApplicationUsers.User
& "tbl_ApplicationUsers.User
& "From tbl_ApplicationUsers " _
& "WHERE(tbl_ApplicationUser
& "ORDER BY UserLName ASC;"
rst.CursorLocation = adUseClient
rst.Open sSqlSupvr, App_Conn, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
strSupvrName = rst("UserLName") & ", " & rst("UserFName")
Me.cboSupvr.AddItem strSupvrName
>> if strSupNameLookingFor = strSupvrName then
>> blnSupFound = True
>> End if
rst.MoveNext
Loop
>> If blnSupFound = False then
>> Me.cboSupvr.AddItem "NONE"
>> End if
You can do it in your SQL too ...
Select tbl_ApplicationUsers.UserL Name, " _
& "tbl_ApplicationUsers.User FName, " _
& "tbl_ApplicationUsers.User Department " _
& "From tbl_ApplicationUsers " _
& "WHERE(tbl_ApplicationUser s.UserSupe rvisor = True) " _
& "ORDER BY UserLName ASC;"
UNION
SELECT TOP 1 'None', '','' FROM tbl_ApplicationUsers
Select tbl_ApplicationUsers.UserL
& "tbl_ApplicationUsers.User
& "tbl_ApplicationUsers.User
& "From tbl_ApplicationUsers " _
& "WHERE(tbl_ApplicationUser
& "ORDER BY UserLName ASC;"
UNION
SELECT TOP 1 'None', '','' FROM tbl_ApplicationUsers
Do While Not rst.EOF
strSupvrName = rst("UserLName") & ", " & rst("UserFName")
Me.cboSupvr.AddItem strSupvrName
rst.MoveNext
Loop