Populate field based on previous entry

A

Amelia

Here is what I want to accomplish. I have an OrdTbl that holds the [PO#],
[OrderDate], and other fields not neccessary for what I want to do.

Okay, now in my inventory form I have a field [PO#] and [PurchaseDate]
field. I want it to automatically populate the purchase date once I enter the
PO#. I know I am missing some sort of link, but I don't know what it is. If I
do a query to pull the data and then create a form, I get a mismatch error in
the query.

Hopefully this makes some sort of sense to someone and they can help me!

(I am pulling the OrdTbl from our Purchase Order Database into our Inventory
Database if this makes a difference)
 
K

kismert

Sounds like what you really want to do is set the Default Value of the
Purchase Date control to Date(). That will set it to the current date for a
new record.

-Ken
 
K

kismert

Sorry, reading too fast.

Is PurchaseDate the same as OrderDate, or is PurchaseDate a field in the
OrdTbl for an inventory item?

If so, you can use a DLookup, like:
DLookup("[PurchaseDate]","OrdTbl","[PO#]='" & txtPONumber & "'")
where txtPONumber holds the PO on your inventory form.

A deeper question is: is this duplication really necessary? If the PO# is a
unique key to OrdTbl, you can reference all the information in OrdTbl by
joining it to the Inventory table in a query.

-Ken
 
M

Mike Painter

Amelia said:
Here is what I want to accomplish. I have an OrdTbl that holds the
[PO#], [OrderDate], and other fields not neccessary for what I want
to do.

Okay, now in my inventory form I have a field [PO#] and [PurchaseDate]
field. I want it to automatically populate the purchase date once I
enter the PO#. I know I am missing some sort of link, but I don't
know what it is. If I do a query to pull the data and then create a
form, I get a mismatch error in the query.

Join the two tables and use that query to build your forms, then use the
PurchaseDate from the OrdTbl.
This is the "proper" way to use a relational database.
There is no need for coding and once done you can use this query anyplace,
thus saving both additional coding and the "oops I forgot that." when you
forgot to do the coding.

While DSOSOL applies more to the emergency medicine field it also applies
when they ask you to make a change that will require recoding if you don't
use queries.


(DSOSOL = Don't Say "Oh Shit" Out Loud.)
 

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

Top