Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Posts
    23

    Unanswered: Comparing Contents of a List Box with a Combo Box

    I am using Access 97, and I'm trying to compare a single value of a list box (list01) to a single value of a combobox (combo01). The list box is made up of one single value and is shown as the result of an SQL statement in the code builder. The combo box has a few options that are generated by a query and the RowSource property takes in that query. I am using the following statement to try to compare the value of the list box to the value of the combo box with a simple error message if the expression is true:

    If (Me!list01.Value = Me!combo01.Value) Then
    MsgBox "Error Message!"

    However, the result is always turning up false because list01.Value is returning a Null value when the combo01.Value is actually returning the selected value. Both fields contain text values, but I don't know what property to use for the list box to compare the value of it to the value of the combo box. Obviously Value seems to be the wrong one to use, so I tried RowSource among a few other things. Nothing worked yet. Any help someone can provide would be greatly appreciated!

    Thanks much!

    littlemadfox

  2. #2
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120
    I put this code behind a command button.

    If Me.Combo.Column(0) = Me.List0 Then
    MsgBox "IT'S A MATCH"
    End If

    Combo is your ComboBox
    List0 is the ListBox

    HTH
    Michael

  3. #3
    Join Date
    Jul 2002
    Posts
    23
    Michael-

    I tried what you suggested, but that didn't work. The Me.list0 value was still showing as a "Null" value, while the Me.Combo0.Value was returning a real value such as "Work." Thus, the If statement is comparing "Work" to "Null" and that will result as false everytime. Do you have any other suggestions? Thanks for trying....appreciate it.

    littlemadfox

  4. #4
    Join Date
    Mar 2002
    Location
    Sacramento, CA
    Posts
    120

    See if the answer is here

    I have whipped up a mini sample to cover all possibilities (I think)


    It is in Acc 2000.

    HTH

    Michael
    Last edited by mrabrams; 06-10-03 at 10:48.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •