Results 1 to 4 of 4
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Row Source in Combo Box Question

    Hi all,
    One more thing i am having issues with.
    I have a tblReference that has ReferenceID (AutoNum), BusinessID(Num), ReferenceName(txt)

    What I am seeking to do in my combo is select only the Reference Names that are associated to BusinessID's

    I have used both the followings rowsource's and neither one works.

    Code:
    SELECT [tblReference].[ReferenceID], [tblReference].[BusinessID], [tblReference].[ReferenceName] FROM tblReference "WHERE BusinessID = '" & Me.BusinessID & "'" ORDER BY [ReferenceName]; 
    
    SELECT [tblReference].[ReferenceID], [tblReference].[BusinessID], [tblReference].[ReferenceName] FROM tblReference "WHERE BusinessID = " & Me.BusinessID & "" ORDER BY [ReferenceName];
    Any help would be wonderful.... I beleive the where statement is the problem but cant figure out what i am doing wrong with it?
    Thanks


    Dave

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,002
    If this is in the underlying query then you need to use the form references.

    Code:
    SELECT [tblReference].[ReferenceID], [tblReference].[BusinessID], [tblReference].[ReferenceName] 
    FROM tblReference 
    WHERE BusinessID = Forms!YourFormName!TxtBoxControlBusinessID ORDER BY [ReferenceName];
    If you are building it VBA then your concatenation is all out of kilter ;

    Code:
    SELECT [tblReference].[ReferenceID], [tblReference].[BusinessID], [tblReference].[ReferenceName] 
    FROM tblReference WHERE BusinessID = " & Me.BusinessID & " ORDER BY [ReferenceName]"
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Worked like a charm
    Thank you very much!
    Dave

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,906
    If you put all that into a string variable, then you can Debug.Print that variable.?
    That then normally shows you, where you have gone wrong.
    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

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

Similar Threads

  1. Replies: 4
    Last Post: 04-26-2020, 02:33 AM
  2. Replies: 19
    Last Post: 06-26-2018, 07:13 AM
  3. Row Source Question
    By datahead in forum SQL Server
    Replies: 4
    Last Post: 06-07-2015, 04:53 PM
  4. Replies: 1
    Last Post: 11-28-2013, 10:03 PM
  5. Replies: 3
    Last Post: 12-11-2012, 09:12 AM

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