compare text box to combo box list

Posted on 2009-12-16
Medium Priority
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
  • 2
LVL 39

Accepted Solution

thenelson earned 1000 total points
ID: 26063625
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

Expert Comment

ID: 26064602
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

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

Expert Comment

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

Happy computing!


Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

862 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