?
Solved

Add (NONE) to Combo List

Posted on 2001-06-22
4
Medium Priority
?
236 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 120 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 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