compare text box to combo box list

Posted on 2009-12-16
Last Modified: 2012-05-08
I have a button that deletes a Purchase Requesition form.  I have the button set up for the person who entered the form can delete it.  I would like to allow some managers to be able to delete the form also.  

I have a combo box (ApprovalCombo) that lists all the managers - I am using this list for the apporval process.  I have "UserLogName" = Environ ("username") - so when the manager selects his name from the combbox I can compare with the username of the PC to allow approval.

What I would like to do for the delete is to compare the UserLogName to all the values listed in the combo box - If the UserLogName is on the list - they can delete the form.

Thanks for your help.
Question by:johnmadigan
    LVL 39

    Accepted Solution

    Where are the values listed in the combo box coming from?

    A table or query? Use:
    If DCount ("AnyFieldInTableOrQuery",  "TableOrQueryName", "UserLogNameFieldName" = " & UserLogName) Then

    A value List? Use:
    If InStr (ComboboxName.RowSource, UserLogName) Then
    LVL 8

    Expert Comment

    Hi johnmadigan, here is example code for VB6:

                    With ApprovalCombo
                        For j = 0 To .ListCount - 1
                            If .ItemData(j) = UserLogName Then
                                ' allow delete here
                                Exit For
                            End If
                    End With

    Author Closing Comment

    Thanks - the "If InStr (ApprovalCombo.RowSource, UserLogName) Then" worked perfectly - just what I needed - thanks for your help!
    LVL 39

    Expert Comment

    You're welcome.  Glad to help and thank you very much for the points with "A" grade!

    Happy computing!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    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…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now