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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling txt boxes from another text box 1

Status
Not open for further replies.

Egglar

Technical User
Apr 4, 2002
88
GB
Hi

I have a table, tblSupplier, and a form frmPurchaseInvoice, there are two text boxes on the form, txtSupplierShortName and txtSupplierFullname.

When the user types in the short name, i want the second txt box to fill with the full name found in tblSupplier.

Im guessing the best way of doing this is the after update function of txtSupplierShortName?

I have tried various methods but none seem to work

Any help would be greatfully recieved, many thanks.
 
=DLookup("[SupplierFullname]", "tblSupplier", "[SupplierShortName]='"&Forms!frmPurchaseInvoice!txtSupplierShortName & "'")
 
Thanks for ur reply but thats not working on my screen?

I added that to the got focus event on txtSupplierFullName, that right i think? But it doesnt fill the txt box with the full name just leaves it blank?

Elliot.
 
Try putting this

txtSupplierFullname = DLookup("[SupplierFullname]", "tblSupplier", "[SupplierShortName]='"&Forms!frmPurchaseInvoice!txtSupplierShortName & "'")

behind your txtSupplierShortName lost focus.
 
Another quick question, can i use the vb code to update a field, eg.

I want to take the SupplierID from tblSupplier based on the Short name put in, and write it in tblPurchaseInvoice.SupplierID

Is this possible?
 
Anything is possible ;)
And, yes, it is possible. Use the same DLookup function. Besides, You can also use SQL queries in your code.
 
I just managed to do it my self using the same method as above but writing it to a hidden text box then setting that text box`s control source to tblPurchaseInvoice.SupplierID

Is there a way of writing it directly to the table, as using a hidden text box seems a bit inpropper?

Also if you have any information on controlling fields in a table from visual basic or can point me in the direction of some information, this owuld help a lot as im pretty good with vb, but not accessing tables in access from it.

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top