Pass Data to new form

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi All,

I have a button that I have added to one form. When clicked it opens another
the form I want to pass the ID from the one for to the newly opened for to
start a new record. How would I do that in the on Click event?

Matt
 
M

Mr. B

mattc66,

Use the "OpenArgs" property of the OpenForm command like:

Dim lngRecordID as long
lngRecordID = Me.NameOfControlWithIdValue

DoCmd.OpenForm("SomeFormName"),,,,,,lngRecordID

Then in the OnOpen event your other form you can have code that will read
the OpenArgs value and write it to the proper control:

Me.NameOfIdControl = Me.OpenArgs

HTH
Mr. B
askdoctoraccess dot com
 
M

mattc66 via AccessMonster.com

Thanks I will give that a shot.

Mr. B said:
mattc66,

Use the "OpenArgs" property of the OpenForm command like:

Dim lngRecordID as long
lngRecordID = Me.NameOfControlWithIdValue

DoCmd.OpenForm("SomeFormName"),,,,,,lngRecordID

Then in the OnOpen event your other form you can have code that will read
the OpenArgs value and write it to the proper control:

Me.NameOfIdControl = Me.OpenArgs

HTH
Mr. B
askdoctoraccess dot com
[quoted text clipped - 3 lines]
 

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