Results 1 to 3 of 3
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111

    Darn concatenation of variables and text VBA Access woes

    Code:
    UID = Me.cmbox_1.Value + "-" + Me.txtField1.Value
    UIDCount = DCount("[CarID]", "Cars", "[Cars.CarID] Like '" & UID & "*'")
    
    If UIDCount > 0 Then 
      do something, 
    Else exit sub
    End If
    UID is concatenated values from two values entered on a form.
    I am trying to take this concatenated value and query the cars table to see it contains the string UIDCount




    Say the UID is Honda-Civic
    In my cars table I have the values in the field CarID

    Honda-Civic-Red
    Honda-Civic-Blue

    Then the UIDCount would return a value of two.

    The problem is it returns the value 0. Ideas as to why?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    The preferred concatenation character is &, although + should work in this case. Otherwise, code looks good to me.

    Have you step debugged? Is the UID variable getting properly set?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    111
    You right. For some reason that honestly escapes me, the code would not work until I completely exited the database and reentered it again.

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

Similar Threads

  1. Dlookup multiple text criteria from vba variables
    By trevor40 in forum Programming
    Replies: 4
    Last Post: 02-03-2015, 04:20 PM
  2. Me.Filter with variable woes
    By chris.williams in forum Programming
    Replies: 3
    Last Post: 08-21-2012, 01:03 PM
  3. Replies: 3
    Last Post: 11-04-2011, 01:50 PM
  4. Combo Box Woes
    By tbassngal in forum Forms
    Replies: 2
    Last Post: 09-01-2011, 08:54 AM
  5. Combo box woes...
    By jonbonazza in forum Forms
    Replies: 3
    Last Post: 06-21-2010, 11:34 AM

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