Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

microsoft access training class - move field data between

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » microsoft access training class - Move Field data between forms

microsoft access training class - Move Field data between forms

ResolvedVersion Standard

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

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Access tip:

Splittng a database

Split your database into two (at least).

Keep all of your code, forms, reports, etc. in one 'code' database and all of your tables in another 'data' database which is then linked to the 'code' database.

This makes modifications, updates and back-ups that much easier and allows you to work on a new version of your 'code' database without affecting existing users. It also makes it easier should you wish to convert a single user databases into a multi-user networked version.

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.