Jenny has attended:
Access Intermediate course
Access Advanced course
Access VBA course
Move Field data between forms
I Have a customer table with the Primary Key of CustID - This is an AutoNumber. A Customer can have one or pets (details stored in another table linked via CustID)
I have a form to Add a customer then a button on this form to take me to the add Pet Form, as the pet has to relate to the Customer Form i want to carry the CustId from the first form to the second form.
For example i add a customer who's CustID = 1 who has a a pet. I click the Add Pet Form and the form opens in add mode with the field CustID on. I want the CustID to be prefilled with 1, so the records are linked.
I believe i should be able to do this with an argument - but am unsure of the code
Thanks
RE: Move Field data between forms
Hi Jenny
Create a macro that you will attach to the button as follows:
OpenForm
- PetForm
- Add Mode
SetValue
ITEM Field - [Forms]![Pet]![Cust]
Expression Field - [Forms]![customer]![customerId]
That shoud do it.
Also look under "SETVALUE ACTION" in the help menu. I am using Access 2003, and they give an example right at the end of exactly what you are wanting to achieve (I simplified it for you).
Let me know how you go.
Regards
Richard
RE: Move Field data between forms
Thanks for the quick answer - Im not brilliant at macros ( tend to use VBA more)
I can set up the macro to open the pet form in add mode, then where do i add the
SetValue
ITEM Field - [Forms]![Pet]![Cust]
Expression Field - [Forms]![customer]![customerId]
Is this added when setting up the macro or is it added to the button or added to the field in the form??
Thanks
RE: Move Field data between forms
SetValue is a command in the macro Action column.
So the first command is OpenForm
then the next line will be Setvalue
regards
Richard