Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Carmarthen
    Posts
    5

    Red face Unanswered: Pass a value from a table to a variable

    I have a variable that i have initialised add1, i want to pass it the value of whatever is in the field address1 in the table tblBusinessAddresses.

    Please has anyone got any ideas how to do this.

    Thanks in advance

    Dwayne

  2. #2
    Join Date
    Oct 2003
    Location
    Boston, MA
    Posts
    15

    Re: Pass a value from a table to a variable

    Originally posted by dwaynej84
    I have a variable that i have initialised add1, i want to pass it the value of whatever is in the field address1 in the table tblBusinessAddresses.

    Please has anyone got any ideas how to do this.

    Thanks in advance

    Dwayne
    one way is to first open a recordset of the table (but before you can do that you must must open a database object):

    dim db as database
    dim rs as recordset
    dim add1 as string 'I'm assuming here that add1 is an address, and as such would be a string

    set db = currentdb()
    set rs = db.openrecordset("tblBusinessAddresses")
    rs.movelast
    rs.movefirst

    add1 = rs("address")

    NOTE: the line "rs.movefirst" puts you on the first record of the recordset object, which in this case is the first record of the table "tblBusinessAddresses"

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: Pass a value from a table to a variable

    Originally posted by dwaynej84
    I have a variable that i have initialised add1, i want to pass it the value of whatever is in the field address1 in the table tblBusinessAddresses.

    Please has anyone got any ideas how to do this.

    Thanks in advance

    Dwayne
    Do you have a particular record that you want to select?

    If you're in a form whose recordsource includes the field you want to store, you can pass the currently displayed value to the variable.

    Not sure of the context of the question so this is just a shot in the dark.

    Gregg

Posting Permissions

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