Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2003
    Posts
    4

    Unanswered: simple access function

    Hi, would someone please assist with this. It seems like no one is able to answer my question.

    Attached is my database. It has a table and a form. The table has 2 columns - "Name" and "Phone."

    Form has a combo box and a text box. Combo box pulls its values from Table's "Name" column.

    Objective: when a name is selected on the combo box, the corresponding phone number for that person should appear in the "Phone" box.

    Thanks!!
    Attached Files Attached Files
    • File Type: zip 1.zip (79.4 KB, 15 views)

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    First I see the problem in your Base, later I send to you the Base with
    the update.
    OK ??
    Saludos
    Norberto

  3. #3
    Join Date
    Oct 2003
    Posts
    4
    Originally posted by Norberto
    First I see the problem in your Base, later I send to you the Base with
    the update.
    OK ??
    Yes! Thank you!

  4. #4
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Sorry but a need your Base in Access 97
    OK??
    Saludos
    Norberto

  5. #5
    Join Date
    Oct 2003
    Posts
    4
    Originally posted by Norberto
    Sorry but a need your Base in Access 97
    OK??
    here u go
    Attached Files Attached Files

  6. #6
    Join Date
    Aug 2003
    Posts
    47

    Re: simple access function

    Yo

    Here's simple working function.
    Attached Files Attached Files
    • File Type: zip 1.zip (79.6 KB, 16 views)
    F..ck it, gimme a beer... Jimi Hendrix RULES!

  7. #7
    Join Date
    Aug 2003
    Posts
    47

    Re: simple access function

    The function that I sent ya looks like this:

    'Here's your function. First off I changed the "Name to "Phone" and "Phone" to "ID"
    'Second cboName.Column(0) refers to the first column of your combo box which has
    'ID values from your "Users" table. You can use it to look up your data.
    ' & operator appends that number to the look up string so the whole thing looks like this:
    ' "ID=1" or "ID=2"
    Private Sub cboName_AfterUpdate()
    txtPhone = DLookup("Phone", "Users", "ID=" & cboName.Column(0))
    End Sub

    You could also use 'cboName.Value' in place of 'cboName.Column(0)' because it has the same data.
    F..ck it, gimme a beer... Jimi Hendrix RULES!

  8. #8
    Join Date
    Aug 2003
    Posts
    47
    I forgot to mention that 'cboName.Value' comes from 'Bound Column' on the 'Data' tab property of this combo box. By default its' set to 1 but if you set it to 2 then 'cboName.Value' would contain second column's data (first column is hidded) which is "Name" and you could also use it to look up "Phone" using 'cboName.Column(1) or cboName.Value BUT using "ID" is better because it's unique.
    F..ck it, gimme a beer... Jimi Hendrix RULES!

  9. #9
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    dygital
    I send your Base with the Update.
    The error is in the Dlookup function, see the use of their parameters.
    Attached Files Attached Files
    Saludos
    Norberto

Posting Permissions

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