Results 1 to 13 of 13
  1. #1
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17

    Combo boxes on form not populating table

    Hi all,



    I'm building my first Access DB for a while, so am a little rusty, but I can't seem to work out this problem.

    I've bound my form, and all of the other fields are saving and populating the correct table, but I have two combo boxes, both of which populate a series of other text boxes based on the selection (eg. I select Joe Bloggs in one box, and it automatically puts Joe Bloggs' phone number and email address in two following boxes).

    This all works, however when I save the record, or move to the next one, the data entered in the combo boxes and the related populated fields doesn't save - they just show up as blank in the record created in my table.

    As an aside, how do I get the combo boxes & related text fields to show a default blank value until a value is selected.

    Any help appreciated - I'm tearing my hair out over this!

    Mads
    xxxxx

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are the "other boxes" bound to fields in the RecordSource of the form?

  3. #3
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17
    I think so - I'm working in Access 2007, which field would that be? I have code in the Control Source field, obviously, (=Combo20.column(2)) etc, but I added the text fields to the form initially by selecting from the 'Add Existing Fields' list, so they should be bound to the correct fields, or is the code in the Control Source field messing that up?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The ControlSource of the TextBoxes needs to be a field in your RecordSource and not the code you have. Populate the TextBoxes in the AfterUpdate event of your ComboBoxes instead.

  5. #5
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17
    Ah, you see that throws me into territory I've not been in before - I've only ever worked with the code in those fields in the past. How would I phrase the AfterUpdate event?

    Sorry to be a real noob!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Me.TextBox1 = Me.Combo20.column(2)
    Me.TextBox2 = Me.Combo20.column(1)
    ...etc - using your TextBox names of course.

  7. #7
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17
    Thanks so much RuralGuy - that's working like an absolute dream, really appreciate it!!! Just as an aside, other than doing something really simple and including a blank row at the top of the table the combo-box pulls from, is there an easy way of having all the fields blank until something is chosen from the combo box?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Does the ComboBox have a ControlSource or is it unbound? Bound controls will display the field to which they are bound.

  9. #9
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17
    It's bound to its corresponding field in the table that the form is entering data into - I think in my duncehood I assumed it wouldn't populate the associated field if it wasn't bound?

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If it is not bound, it has nothing to display. If you need it bound then it will display something. BTW, it sounds like you are duplicating values in more than one table. It should be possible to display the values you want without copying them to another table. It can be done with a simple relationship if the tables are defined properly.

  11. #11
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17
    It's a lookup field in a table that records requests, so the person requesting something can choose their own name from the combo-box and have all of their contact details automatically populated - the combo box pulls information from a table that holds all of the individuals' names and contact details

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  13. #13
    Madraykin is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2010
    Posts
    17
    Ouch indeed - it really has been a long time since I did my Access training hasn't it!

    Well, there goes my weekend, I'll be working out how to sort this darn thing out for next week. Thanks so much for all your help, I'm off home, time to self-medicate with a good drink methinks, that will help my brain work. Honest......

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

Similar Threads

  1. Populating table from combo box
    By mcguires99 in forum Forms
    Replies: 4
    Last Post: 12-13-2011, 09:48 AM
  2. Replies: 7
    Last Post: 09-06-2011, 08:00 PM
  3. Replies: 1
    Last Post: 08-13-2011, 12:03 AM
  4. Incorrect Values Populating My Combo Boxes
    By charlyzaingel in forum Forms
    Replies: 19
    Last Post: 06-23-2011, 10:17 AM
  5. Replies: 3
    Last Post: 12-17-2010, 06:31 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