Results 1 to 5 of 5
  1. #1
    gpierce9 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    NJ
    Posts
    19

    Combo filter bad message. Trying to use 2 combo fields on a form.

    2/24/2018 Hello. I am having trouble with the 2nd combo box.


    I get an criteria type of error.

    The 1st combo is where I enter or pull down a STATE.
    The 2nd combo is then supposed to show me the Airports applicable to that State.

    For example, if I enter FL for florida in combo 1 and then I go over to combo 2 pull down,
    UP pops the error message. For the heck of it, I entered FL into the error message.

    I got what I wanted. I get to pick the desired airport.

    So this combo dependent deal is almost working. I am doing something wrong.
    I have this design for other places and it works. But not here.

    You will notice in the 2nd combo box, inside the After Update, I have a criteria in the state field.
    It is identical to the error message. So maybe I have something wrong in that criteria row ??

    I looked around the forum and internet but just can't find an answer.
    Small zipped file is attached. The frmCustomer holds the 2 combo boxes noted in Yellow.
    Thanks. Glen.
    Attached Files Attached Files

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Change rowsoruce for cboMailRegionDataID to:
    Code:
    SELECT tblMailRegion.MailRegionID, tblMailRegion.MailRegionName, tblMailRegion.AirportID, tblMailRegion.State FROM tblMailRegion WHERE tblMailRegion.State=[cboMailRegionState];

  3. #3
    gpierce9 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    NJ
    Posts
    19

    Thanks Dave - It worked.

    Quote Originally Posted by davegri View Post
    Change rowsoruce for cboMailRegionDataID to:
    Code:
    SELECT tblMailRegion.MailRegionID, tblMailRegion.MailRegionName, tblMailRegion.AirportID, tblMailRegion.State FROM tblMailRegion WHERE tblMailRegion.State=[cboMailRegionState];
    I have attached a zipped file again for posterity!
    In case anyone else needs this. Dave did a nice job for me.

    2comboTest3.zip

    Glen
    Attached Files Attached Files

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Glad to help.
    When you use expression builder for creating criteria, expression builder doesn't know where the code it is generating will be used. So, it creates full object names for for controls on forms.
    If you know the code is to be executed on the form, you can strip off that [Forms]![frmName]! prefix stuff.

    BTW, I like your GUI design for the form. Looks nice.

  5. #5
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    A couple of comments.....

    EVERY module should have
    Code:
    Option Compare Database
    Option Explicit
    as the top 2 lines.



    Instead of syntax like
    Code:
       Me![cboMailRegionDataID].Value = Null
       Me![cboMailRegionDataID].Requery
    you should use
    Code:
       Me.cboMailRegionDataID = Null
       Me.cboMailRegionDataID.Requery
    The brackets are only required if the name is a reserved word, has spaces or has special characters/punctuation.
    "Value" is the default property, so while it doesn't hurt, it is not necessary (and saves you typing time)

    Also note that "STATE" is a reserved word in Access and shouldn't be used as an object name.
    See http://allenbrowne.com/AppIssueBadWord.html

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

Similar Threads

  1. Replies: 2
    Last Post: 03-18-2016, 08:39 AM
  2. Replies: 1
    Last Post: 02-28-2016, 04:14 AM
  3. Replies: 11
    Last Post: 09-03-2015, 11:12 AM
  4. Replies: 11
    Last Post: 11-28-2012, 04:29 PM
  5. Replies: 3
    Last Post: 10-07-2010, 09:36 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