How to pass a value from one form to another?

R

Rusty Shackelford

I have a form based on a query that is for incoming paperwork. The key for
the first form is called memoID this form gets filled out for all paperwork.
If there is a problem with the paperwork there is a command button that
saves the record and opens the second form.

Dim stLinkCriteria As String
stDocName = "frmOrderError"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd

But to get the new error form to be related to the original from/record the
user has to manually enter in the memoID from the first. I would like for it
to be entered automatically. I also want to build a report that is generated
by command on the second form that is based on the key from the second form.
Can someone point me in the right direction?
Thanks,
 
N

Naresh Nichani MVP

Hi:

Use OpenArgs when opening the form like this

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd,,Me.MemoID

Here the MemoID is passed to new Form -- the strDocName form can access the
MemoID with Me.OpenArgs in code.

Regards,

Naresh Nichani
Microsoft Access MVP
 

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