Results 1 to 3 of 3
  1. #1
    cheese9799 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2011
    Posts
    11

    Problems with the possible values of one combo box depending on the value of another

    SOLVED



    I have 2 combo boxes. The first one selects a category, and then the second should then display all the possible values from that category. And it does that. The following code is used:



    In the AfterUpdate of the 1st combo box:

    Private Sub cboCertificateType_AfterUpdate()
    Me.cboJobType = Null
    Me.cboJobType.Requery
    End Sub

    (where the 1st combo box is called 'cboCertificateType' and the 2nd combo box is called 'cboJobType')


    The query for the 2nd combo box is:

    SELECT tblJob.idsJobID, tblJob.chrJobType
    FROM tblJob
    WHERE (((tblJob.lngCertificateID)=[Forms]![frmBooking]![cboCertificateType]));

    (and you'll just have to trust me that those table, field and form names are correct)



    Now this works partially. I do get the option to select a category, and then I do then get a selection of all of the available value in that category. However, when pressing the left/right arrow to browse through records, the 2nd combo box is empty whenever the 1st combo box is not equal to the last one I selected.

    It's quite hard to explain so here's an example: I select the option 'Installation', which provides a list of jobs that come under 'installation'. I select one of them. Now I press the back arrow to move back to the previous record, and because the category of that record was 'minor', and not 'installation', the value of the second combo box is blank.

    The actual records saved in the table don't disappear, but it just appears blank when browsing through the records through the form.

    The following solution failed:

    Private Sub Form_Current()
    Me.cboJobType = DLookup("chrJobType", "tblJob")
    End Sub

    I get 'The value you entered isn't valid for this field.'

  2. #2
    cheese9799 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2011
    Posts
    11
    Solved - just had to add another Me.cboJobType.Requery in the form OnCurrent event

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    There are free video tutorials here.
    This one has 2 combo boxes. The subject you are dealing with is Cascading Combo boxes.

    http://www.datapigtechnologies.com/f...combobox2.html


    Also nothing is = Null

    I think you're looking for IsNull() function

    see http://allenbrowne.com/casu-12.html

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

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2010, 06:13 AM
  2. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  3. Replies: 3
    Last Post: 02-26-2009, 10:17 AM
  4. Form Combo problems
    By Honeytree in forum Forms
    Replies: 0
    Last Post: 10-05-2008, 01:32 PM
  5. Problems with list or combo box on tabbed form
    By kydbmaster in forum Forms
    Replies: 0
    Last Post: 02-20-2008, 01:33 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