Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2003
    Posts
    22

    Post Unanswered: Please help me... - More Combo Box Questions

    Another combo box question....

    All I need is for the second combo box to update its list of choices depending on what is selected in the first combo box. The form being used is "frmAddAsset". The Combo boxes are "cboDeparmentID" and "cboDivision". I have read the previous posts on this topic but I still cant get it working. I almost have it working... When you pick your first selection a box pops up and asks you to enter the value instead of using the value you picked. If you type it in it does work, so i must almost have it working.

    Can someone please look at it for me.
    Thanks,
    Newbie
    Last edited by jimslim; 06-24-03 at 08:39.

  2. #2
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

  3. #3
    Join Date
    Jun 2003
    Posts
    22

    Question Confused

    I still cant get it to work

    My first combo box is: cboDeparmentID
    The one I want to update is: cboDivisionID

    cboDeparmentID control source is: DeparmentID from tblDeparment
    cboDivisionID contorl source is: DivisionID from tblDivisions
    my form is: frmAddAsset

    So how would I modify the following code to work with my form?

    Code****************************

    Hi psmithphil,

    Another way to go is as follows:

    At the AfterUpdate event of LocationID, add the following come:

    Me.RecordSource = "SELECT * FROM Assets WHERE LocationID = " & Me.LocationID.Value
    Me.Requiery

    This will populate only the fields in Assets where LocationID = [BoxSelection].


    Regarding TheNextStep's suggestion, it is a good practice to add:
    Private Sub TheNameOfYourComboBox_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[The name of your field] = " & Str(Me![The name of your combo box])
    Me.Bookmark = rs.Bookmark

    'Addition!
    'Close the recordset and release it's memory....
    rs.Close
    End Sub

    This will save you a LOT of head akes....

    Hope this helps,

    Nosterdamus

    Code****************************


    Sorry but I have been using Access for a total of 2 days, I am very new to this.

  4. #4
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: Please help me... - More Combo Box Questions

    Here..i downloaded the attachment and fixed the problem..
    there were couple of problems.
    1-DeparmentID should be DeparTment ID..(didnt fix that)
    2-no link between Department and tblDivions(created that)
    3-threw UNBOUND combobox on Asset form.
    4-All my coding is under
    Private Sub cboDeparmentID_AfterUpdate()

    i commented well for you and u will understand perfectly step by step.

    Cheers,
    vbaprogrammer
    (just in case to go to VBA , just press ALT+F11)
    Attached Files Attached Files

  5. #5
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: Please help me... - More Combo Box Questions

    Here..i downloaded the attachment and fixed the problem..
    there were couple of problems.
    1-DeparmentID should be DeparTment ID..(didnt fix that)
    2-no link between Department and tblDivions(created that)
    3-threw UNBOUND combobox on Asset form.
    4-All my coding is under
    Private Sub cboDeparmentID_AfterUpdate()

    i commented well for you and u will understand perfectly step by step.
    check out the attachment please.
    Cheers,
    vbaprogrammer
    (just in case to go to VBA , just press ALT+F11)
    Attached Files Attached Files

  6. #6
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: Confused

    One thing I would like to mention out is that ur making ur life so difficult the way u set up the RELATIONSHIPS.
    Make it easier....only connect those which are necessary , in ur case ur attaching all the tables to one. in my opinion thats not the right and safe approach for beginner at all.

    check out the relationship i modified between tblDepartment and tblDivision by clicking on Tools, then click on Relationships.

    Cheers.

  7. #7
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: Please help me... - More Combo Box Questions

    make sure to add DAO 3.5 by Pressing ALT+F11 then Click on Tools,then References ,then check Microsoft DAO 3.6 Object Library.
    Thanks,
    Newbie [/SIZE][/QUOTE]

  8. #8
    Join Date
    Jun 2003
    Posts
    22

    Red face

    Thanks for all your help!

    I can't believe i spelled DeparTment wrong...

    I know my relationships probably aren't maped out to well, but I am just trying to learn this whole database thing from the internet and microsofts help files...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •