Results 1 to 12 of 12
  1. #1
    bbulla is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    4

    Comparing two string values

    I'm trying to compare two string values as part of an IF THEN expression. For some reason it's not working. I'm comparing the ComboBox.Value to a string. From looking at the watch window it returns FALSE, but why?? Everything seems to match up. See the image attached.

    Do i need to do some sort of conversion of the ComboBox.Value?? I've tried to CStr it, but that errors out.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	24 
Size:	77.4 KB 
ID:	51463

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    What is the "Row Source" property setting o the combo box?
    It could be that the combo is retrieving 2 columns of data. The first being a hidden column with a numeric primary key value and the second column being a text value, like someone's name.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    bbulla is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2011
    Posts
    4
    Hi Bob,

    The row source is a query that returns the name and e-mail of each employee. The combo box is bound to the "1"st column....the name of each employee which is a text field in a table.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you show us the SQL statement of the query
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you also paste all the code of the sub procedure in a code window here
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You have a typo?
    Olguin and Olquin
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  8. #8
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    WOW! That is easily missed on my laptop monitor and believe me, I studied those two lines. It's barely discernible even when pointed out. Great catch!
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    bbulla is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2011
    Posts
    4
    OMG....that is amazing!! I thought that at first, and thought I for sure had the spelling right. It even deceived my eyes!!

    Thanks so much...this was driving me crazy.

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by Micron View Post
    WOW! That is easily missed on my laptop monitor and believe me, I studied those two lines. It's barely discernible even when pointed out. Great catch!
    It was the Locals picture that gave it away.
    Plus I have a 17" laptop.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by Welshgasman View Post
    You have a typo?
    Olguin and Olquin
    Great spot Paul . The eye of a forger
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Bob, this will have to do for a LFMAO emoji
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Comparing values between fields
    By Spiken in forum Programming
    Replies: 14
    Last Post: 01-20-2022, 12:53 PM
  2. Comparing values in Access
    By mikesal57 in forum Access
    Replies: 18
    Last Post: 10-18-2021, 02:15 PM
  3. Replies: 4
    Last Post: 03-16-2017, 12:19 PM
  4. If statement comparing 2 values
    By Ekhart in forum Programming
    Replies: 3
    Last Post: 09-15-2016, 11:16 AM
  5. Comparing positive to negative values.
    By rubberducky in forum Access
    Replies: 1
    Last Post: 01-20-2014, 04:44 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums