Pull data from another table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick J

    Pull data from another table

    Hi,

    I have a command button, when I press it I would like it to find the record
    I have specified in a text box on the current form and to pull fields such
    as Address 1 and Address 2 from another table into text boxes on the current
    form.

    The fields that are pulled into the current form need to be stored in the
    table for the current form, so I do not beleive I could use DLookUp because
    they will not be stored? only displayed.

    Many Thanks...

    --

    Kind Regards...

    Customer Services Team
    Blue Bell Trading

    +++ WHEN REPLYING PLEASE DO NOT DELETE ANY OF THE TEXT AS WE NEED IT FOR
    REFERENCE +++

    Blue Bell Trading


  • pietlinden@hotmail.com

    #2
    Re: Pull data from another table

    Normal relational design says you shouldn't have to store them. But
    biz rules trump DB design rules in lots of cases...

    One way to do it would be to open a recordset with the single recordID
    parameter (basically a parameterized query or something like it) and
    then you'd get one record with lots of fields. Then you could just set
    all the fields you wanted...

    can't remember the exact syntax, but you'd do something like

    'all DAO
    dim rs as recordset
    dim qd as querydef
    set qd=dbengine(0)( 0).querydefs("M yQuery")
    set qd.parameters(0 )=Me.Fields("My IDField")
    set rs=qd.openrecor dset

    then you could access the fields in the recordset or whatever...
    me.fields(0) = rs.fields(0)
    or
    me.controls("co ntrolname").val ue=rs.Fields("F ieldName")
    ....
    so ya write it as a function and call it in a macro or whatever. or
    skip that and just call it in a button.'s click event.

    Comment

    Working...