Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Autofill details in a Form

Discussion in 'Information Technology' started by Robert, Jul 28, 2006.

  1. Robert

    Robert
    Expand Collapse
    Guest

    First off, I'm a complete novice who has been landed with the job of building
    a Database. Heres my latest problem.

    I have a Form used to enter order info into a table that will be used to
    plan production.
    I would like to have the details of the Product ordered to autofill, once
    the unique Customer Code & Product Code have been entered into the form (both
    these fields are the primary key on the source table).
    Any suggestions would be great as I am running out of hair to pull out.
     
  2. Loading...


  3. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    A common approach would be to select the Customer and Product codes from
    combo boxes. You'd also have additional information about each customer and
    each product in the RowSource, so that in the AfterUpdate event of the combo
    box, you'd populate the appropriate text boxes by referring to the data for
    the selected row, using the Column collection.

    For example, if you had Customer Name as the 2nd column and Customer Address
    as the 3rd column of cboCustomer, your AfterUpdate event would be something
    like:

    Private Sub cboCustomer_AfterUpdate()

    Me.txtCustomerName = Me.cboCustomer.Column(1)
    Me.txtCustomerAddress = Me.cboCustomer.Column(2)

    End Sub

    (Note that the Column collection starts counting at 0, not 1)

    Another approach would be to do lookups in the related tables in the
    AfterUpdate event of whatever controls you use to accept Customer Code and
    Product Code.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "Robert" <Robert@discussions.microsoft.com> wrote in message
    news:173C4B14-EE6C-4946-B800-8CB26E3A536E@microsoft.com...
    > First off, I'm a complete novice who has been landed with the job of
    > building
    > a Database. Heres my latest problem.
    >
    > I have a Form used to enter order info into a table that will be used to
    > plan production.
    > I would like to have the details of the Product ordered to autofill, once
    > the unique Customer Code & Product Code have been entered into the form
    > (both
    > these fields are the primary key on the source table).
    > Any suggestions would be great as I am running out of hair to pull out.
    >
     
  4. Ofer Cohen

    Ofer Cohen
    Expand Collapse
    Guest

    If this form is also used to navigate between records, and not only for data
    input, then you should put this code in the OnCurrent event of the form.

    Or, instead of writing code, you can add to the control source of the text
    boxes the reference to the combo.
    For example, to add the name to the txtCustomerName then in the control
    source you can write
    = [cboCustomer].Column(1)

    --
    Good Luck
    BS"D


    "Douglas J. Steele" wrote:

    > A common approach would be to select the Customer and Product codes from
    > combo boxes. You'd also have additional information about each customer and
    > each product in the RowSource, so that in the AfterUpdate event of the combo
    > box, you'd populate the appropriate text boxes by referring to the data for
    > the selected row, using the Column collection.
    >
    > For example, if you had Customer Name as the 2nd column and Customer Address
    > as the 3rd column of cboCustomer, your AfterUpdate event would be something
    > like:
    >
    > Private Sub cboCustomer_AfterUpdate()
    >
    > Me.txtCustomerName = Me.cboCustomer.Column(1)
    > Me.txtCustomerAddress = Me.cboCustomer.Column(2)
    >
    > End Sub
    >
    > (Note that the Column collection starts counting at 0, not 1)
    >
    > Another approach would be to do lookups in the related tables in the
    > AfterUpdate event of whatever controls you use to accept Customer Code and
    > Product Code.
    >
    > --
    > Doug Steele, Microsoft Access MVP
    > http://I.Am/DougSteele
    > (no private e-mails, please)
    >
    >
    > "Robert" <Robert@discussions.microsoft.com> wrote in message
    > news:173C4B14-EE6C-4946-B800-8CB26E3A536E@microsoft.com...
    > > First off, I'm a complete novice who has been landed with the job of
    > > building
    > > a Database. Heres my latest problem.
    > >
    > > I have a Form used to enter order info into a table that will be used to
    > > plan production.
    > > I would like to have the details of the Product ordered to autofill, once
    > > the unique Customer Code & Product Code have been entered into the form
    > > (both
    > > these fields are the primary key on the source table).
    > > Any suggestions would be great as I am running out of hair to pull out.
    > >

    >
    >
    >
     
  5. Steve Schapel

    Steve Schapel
    Expand Collapse
    Guest

    Robert,

    There are a number of common approaches to this scenario. Some of them
    are outlined in this article...
    http://accesstips.datamanagementsolutions.biz/lookup.htm

    --
    Steve Schapel, Microsoft Access MVP


    Robert wrote:
    > First off, I'm a complete novice who has been landed with the job of building
    > a Database. Heres my latest problem.
    >
    > I have a Form used to enter order info into a table that will be used to
    > plan production.
    > I would like to have the details of the Product ordered to autofill, once
    > the unique Customer Code & Product Code have been entered into the form (both
    > these fields are the primary key on the source table).
    > Any suggestions would be great as I am running out of hair to pull out.
    >
     
  6. Robert

    Robert
    Expand Collapse
    Guest

    Thanks for the quick response to my problem folks. I will try your suggestions.
    Robert.

    "Robert" wrote:

    > First off, I'm a complete novice who has been landed with the job of building
    > a Database. Heres my latest problem.
    >
    > I have a Form used to enter order info into a table that will be used to
    > plan production.
    > I would like to have the details of the Product ordered to autofill, once
    > the unique Customer Code & Product Code have been entered into the form (both
    > these fields are the primary key on the source table).
    > Any suggestions would be great as I am running out of hair to pull out.
    >
     

Share This Page