Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2014
    Posts
    3

    Unanswered: auto populate txt fields on form open event?

    Hello all, I am putting together a database for my company and have minimal experience with VBA code/macros, except what I am absorbing from reading the forums! Learning a lot and making progress, but recently hit a road block.

    Following are some details regarding my issue:
    - In one of my forms I have a combo box controlled to auto-populate several text boxes during the On Change event (VBA sequence below)

    Private Sub cboEquipment_Change()
    Me.txtOMManual.Value = Me.cboEquipment.Column(2)
    Me.txtShopDrawing.Value = Me.cboEquipment.Column(3)
    Me.txtSpecSection.Value = Me.cboEquipment.Column(4)
    Me.txtWarrantyContractor.Value = Me.cboEquipment.Column(5)
    Me.txtServiceContractor.Value = Me.cboEquipment.Column(6)
    Me.txtRepresentative.Value = Me.cboEquipment.Column(7)
    End Sub

    - After I save and close the form when I re-open the form the auto-populated text boxes are empty and I have to go through the On Change event in the combo box again to re-populate the text boxes
    - Is there a piece of VBA code I can add so that during the open event of the form the text boxes will populate?

    Thanks!
    Chad

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    It sounds as if the Controls in question are not Bound to Fields in the underlying Table; is this a Bound Form?

    Welcome to dBforums!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Oct 2014
    Posts
    3
    Linq,

    The Form is bound to my primary Table. However, the combobox Row Source references a different Table than the Control Source Table.

    Attached is a screenshot of my Form design view.

    Thanks for the quick response!
    Attached Thumbnails Attached Thumbnails DV_Form.jpg  

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by cfinn86 View Post
    Linq,

    ...The Form is bound to my primary Table...
    The Table might be Bound to the Form, but none of the Controls are! In Design View, if you look at the Controls/Textboxes for txtOMManual, txtShopDrawing, txtSpecSection, etc. you will see in each Control the word 'Unbound!'

    Assuming that you actually have the primary Table selected as the RecordSource for the Form, for each Control you need to

    • Select the Textbox Control
    • Go to Properties - Data
    • In the Control Source Property, use the Dropdown Arrow and select the Field to Bind to that Control


    Linq ;0)>
    Last edited by Missinglinq; 10-16-14 at 13:45.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Oct 2014
    Posts
    3
    I followed your steps and made the changes to the Textboxes. The Textboxes are now populated when I open the Form, but I now get the ID# showing in all the Textboxes and the following error when I select from the combo box: "Run-time error '2113': The value you entered isn't valid for the field."

    The field that I am trying to bind to, in my primary Table, is a Lookup field from a secondary Table that has multiple columns of data.

Posting Permissions

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