Results 1 to 4 of 4
  1. #1
    pavarga is offline Novice
    Windows Vista Access 2007
    Join Date
    Jul 2009
    Posts
    4

    Question Dropdown with Union Query on form not working

    I have a form that i want to allow searching on several fields. I have dropdowns set up for this. All work fine except one. It is for Parking Permits. People may have one or two vehicles. Rather than having a search box for vehicle one and vehicle two I wanted just one to search both V1 and V2. I can make this work using a query of both, but it shows as two columns. I made a query so it is all in one column but cannot figure out how to make it work. It returns nothing.


    Grateful for any advice or guidance. I haven't touched Access in years. We use Oracle and SQL Developer for most things. But one user needed this.

    Thanks

    Query:
    SELECT dbo_parkingpermit.UniqueId, dbo_parkingpermit.PermitNumberV1
    FROM dbo_parkingpermit
    ORDER BY 1 Asc
    UNION
    SELECT dbo_parkingpermit.UniqueId, dbo_parkingpermit.PermitNumberV2
    FROM dbo_parkingpermit


    WHERE dbo_parkingpermit.PermitNumberV2 IS NOT NULL;

    Had a condition for both fields, this is just showing one as I deleted it.

    ="[PermitNumberV1] = " & "'" & [Screen].[ActiveControl] & "'"

  2. #2
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    430
    on design view of your form, click on the combo.
    on it's property->Format->Column Widths: 0, 1" (or 2.54 if cm).

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    Looks like denormalised data but a union query should work - syntax would be the same as sql server.

    Not clear about your condition or why you have order by in the first part

    you will have duplicate ID’s if there is a second permit, so the combo will always select the first one assuming that is the bound colunn

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That ORDER BY clause will be ignored. ORDER BY will only be honored when it is in the last SELECT and it will apply to the entire UNION dataset.
    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.

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

Similar Threads

  1. Replies: 9
    Last Post: 10-23-2017, 06:32 PM
  2. Replies: 4
    Last Post: 08-09-2017, 12:06 PM
  3. Convert Union Query to non-union help
    By Ekhart in forum Queries
    Replies: 2
    Last Post: 01-10-2017, 03:39 AM
  4. Replies: 1
    Last Post: 07-09-2014, 03:36 PM
  5. Replies: 9
    Last Post: 05-23-2011, 06:12 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