Solved

Add (NONE) to Combo List

Posted on 2001-06-22
4
234 Views
Last Modified: 2010-08-05
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.UserLName, " _
    & "tbl_ApplicationUsers.UserFName, " _
    & "tbl_ApplicationUsers.UserDepartment " _
    & "From tbl_ApplicationUsers " _
    & "WHERE(tbl_ApplicationUsers.UserSupervisor = 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
0
Comment
Question by:ADawn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 8

Accepted Solution

by:
Dave_Greene earned 30 total points
ID: 6218858
' Fill the Supervisor Combo Box
   
sSqlSupvr = "Select tbl_ApplicationUsers.UserLName, " _
   & "tbl_ApplicationUsers.UserFName, " _
   & "tbl_ApplicationUsers.UserDepartment " _
   & "From tbl_ApplicationUsers " _
   & "WHERE(tbl_ApplicationUsers.UserSupervisor = True) " _
   & "ORDER BY UserLName ASC;"

   rst.CursorLocation = adUseClient
   rst.Open sSqlSupvr, App_Conn, adOpenKeyset, adLockOptimistic

Me.cboSupvr.AddItem "NONE"

   Do While Not rst.EOF
     strSupvrName = rst("UserLName") & ", " & rst("UserFName")
     Me.cboSupvr.AddItem strSupvrName
     rst.MoveNext
   Loop
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6218860
Me.cboSupvr.AddItem "(NONE)"
Do While Not rst.EOF
     strSupvrName = rst("UserLName") & ", " & rst("UserFName")
     Me.cboSupvr.AddItem strSupvrName
     rst.MoveNext
Loop
0
 

Expert Comment

by:nomulap
ID: 6219649
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.UserLName, " _
                      & "tbl_ApplicationUsers.UserFName, " _
                      & "tbl_ApplicationUsers.UserDepartment " _
                      & "From tbl_ApplicationUsers " _
                      & "WHERE(tbl_ApplicationUsers.UserSupervisor = 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
0
 
LVL 4

Expert Comment

by:vindevogel
ID: 6221279
You can do it in your SQL too ...

Select tbl_ApplicationUsers.UserLName, " _
   & "tbl_ApplicationUsers.UserFName, " _
   & "tbl_ApplicationUsers.UserDepartment " _
   & "From tbl_ApplicationUsers " _
   & "WHERE(tbl_ApplicationUsers.UserSupervisor = True) " _
   & "ORDER BY UserLName ASC;"

UNION

SELECT TOP 1 'None', '','' FROM tbl_ApplicationUsers
   
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question