Help Regarding Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help to do this....

I have a table that has employee information such as address and other
stuff. One of the fields it has is Location Number.

I have a different table that has Location Number, City, State, Address,
Phone # Etc.

I have a form with the first table that has the employee information. Here
is my problem, I want to type the Location Number in the Form and have it
automatically retrieve the City, State, Address, and Phone # from the table
and add it to the form in the fields.

Is this possible????

Thanks
 
On the after update event of the Location Number field you can open a
recordset that will return all the values for the Location Number, it's
better then dlookup, because that way you access the table record just once.

Dim MyDB as database, MyRec as recordset
Set MyDB=codedb()
Set MyRec=MyDB.openRecordset("Select * From [Location Table Name] Where
[Location Number] = " & Me.[Location Number Field Name In The Form])
If MyRec.eof then
msgbox "No address for this number"
else
me.City = MyRec!City
me.State= MyRec!State
me.Address= MyRec!Address
me.[Phone #]= MyRec![Phone #]
End If
 
Thank You, worked perfectly!!!

Ofer said:
On the after update event of the Location Number field you can open a
recordset that will return all the values for the Location Number, it's
better then dlookup, because that way you access the table record just once.

Dim MyDB as database, MyRec as recordset
Set MyDB=codedb()
Set MyRec=MyDB.openRecordset("Select * From [Location Table Name] Where
[Location Number] = " & Me.[Location Number Field Name In The Form])
If MyRec.eof then
msgbox "No address for this number"
else
me.City = MyRec!City
me.State= MyRec!State
me.Address= MyRec!Address
me.[Phone #]= MyRec![Phone #]
End If


mjcxp said:
I need help to do this....

I have a table that has employee information such as address and other
stuff. One of the fields it has is Location Number.

I have a different table that has Location Number, City, State, Address,
Phone # Etc.

I have a form with the first table that has the employee information. Here
is my problem, I want to type the Location Number in the Form and have it
automatically retrieve the City, State, Address, and Phone # from the table
and add it to the form in the fields.

Is this possible????

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top