Results 1 to 4 of 4
  1. #1
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393

    Coding different results in same combo box


    Essentially I am trying to find a way to display different sets of data in a combo box dependant on a null value. What I would like to do is display the Cities associated with a certain contact using the following code

    SELECT tblCities.CityID, tblCities.CityName
    FROM tblCities
    WHERE (((tblCities.CityID)=[forms]![frmContact]![txtCityID]))
    ORDER BY tblCities.CityName;

    What I would like to do is if their is no city associated with a contact, or when entering a new contact I would like to display all the cities without any filtering using something like

    SELECT tblCities.CityID, tblCities.CityName
    FROM tblCities
    ORDER BY tblCities.CityName;

    Now I think I need something like

    if CityID IS NOT.NULL --> use first SQL statement if it is NULL use second but I don't know how to do this in SQL or VB?

    Probably a quick one for those in the know

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JFo is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    393
    Great, that is exactly what I was looking for

    Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Happy to help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 08-16-2011, 05:54 PM
  2. Replies: 1
    Last Post: 03-09-2011, 02:04 AM
  3. Bound Object Frame Combo sorted Results
    By kevsim in forum Programming
    Replies: 7
    Last Post: 01-08-2011, 06:30 PM
  4. Combo Box Coding
    By Hale in forum Forms
    Replies: 2
    Last Post: 05-04-2010, 10:56 AM
  5. Coding for Empty Combo Box
    By gazzieh in forum Programming
    Replies: 1
    Last Post: 03-26-2010, 05:22 PM

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