microsoft access training class - move field data between

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

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

resolvedResolved · Low Priority · Version 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:

Choosing data types in Access

Not sure which data type to use for your Access fields? Here are some guidelines to help you choose a data type to assign to a field.

- The Text data type can accept up to 255 characters. For information that will be recorded in paragraphs, use Memo.

- Also use Text for numbers that aren't going to be used in calculations, e.g. phone numbers.

- Use the Currency data type for monetary amounts.

- Use Date/Time for dates.

- Most other numbers can use the Number data type, but the Field Size property may have to be altered.

- For fields that have only two alternatives (yes, no) use Yes/No data type. If there is likely to be a third entry option (e.g. maybe or don't know) use Text instead.

View all Access hints and tips


Server loaded in 0.07 secs.