[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Add (NONE) to Combo List

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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

649 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