Getting Information to display in a textbox

Bullet

New member
Local time
Today, 07:08
Joined
Mar 2, 2009
Messages
8
Hi guys,

What im trying to do it have a form so that when a name is selected from a drop down list the relevant address, phone number etc appears in relevant text boxes below.

Ive created the table with all of the information in it.

Ive got the drop down list to work (in a form) but don't know how to get the text boxes to show the relevant information depending on which name is selected....



Any help would be greatly appricated,

Kind Regards =]
 
Code:
private sub DisplayThis()

    Dim rs as recordset
    Dim sSQL as string
    Dim sVal as String

    txtInformation = ""
    sVal  = ""

    sSQL = ""
    sSQL = sSQL & "SELECT * FROM tblTableName "
    sSQL = sSQL & "WHERE Name = '" & replace(cboName & "","'","''") & "' "

    set rs = CurrentDB.OpenRecordset(sSQL)

    If rs.eof =false then

       sVal = sVal  & rs!FirstName & " " & rs!LastName & "" & vbcrlf
       sVal = sVal  & rs!Address &  vbcrlf
       sVal = sVal  & rs!City& ", " & rs!State & "" & rs!ZipCode & "" & vbcrlf
       sVal = sVal  & rs!PhoneNumber & ""

       txtInformation = sVal 

    End If

    rs.Close
    Set rs = Nothing

End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom