Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autofill a field

Status
Not open for further replies.

kevinluebb

Programmer
Jan 4, 2002
30
US
I have a form with project input information that will be used as a tracking and reporting device for our projects. On the form there are fields for requestor name, phone number, extension. I want to autofill the phone number and extenstion fields based upon the requestor name the user selects from the combo box. There is a table with the requestor name, phone, and ext. I tried the dlookup but it didn't appear to work.
 
Try use DAO/ADO recordset to assign the value to the text field in the form. Something like this:
me.text10 = rst![user name]
 
How bout using the combo-box as a repository for this information? I would set the data set for the combo-box to Select Name, Phone, Exten from Table. Then make the width of Columns 2 & 3 zero. This will keep them from displaying. After a user selects a combo-box value, simply reference the combo-box value and set the fields equal to the appropriate value on the Click event. Again, this is one approach I used once...

Steve Medvid
"IT Consultant & Web Master"
 
What problem where you getting with the Dlookup, following is a Dlookup procedure have a look to see if there was an error with your code.

Private Sub combobox1_change(Cancel As Integer)
Dim strFilter As String
strFilter = "names = " & Me!combobox1
Me!phonenumber=DLookup("Serviceman","tablename",strFilter)
Me!extention =DLookup("extention","tablename", strFilter)
End Sub


Laymans terms.

Private Sub combobox1_change(Cancel As Integer)
Dim strFilter As String
strFilter = "tablereference = " & Me!form reference
Me!formfield=DLookup("tablefieldname","tablename",strFilter)
Me!formfield=DLookup("tablefieldname","tablename",strFilter)
End Sub



Hope this helps

Zero Anarchy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top