EVENT PROCEDURE TO OPEN A SUB FORM TO A CURRENT RECORD

G

Guest

I am trying to set an event procedure to open another form to a current
record. example...

I am working in the daily dispatch log however I now have a form that has
only vehicle information fields linked to the daily dispatch log. I want to
program a command button to click on and open the form to the current record
I am working in and enter the vehicle information and close it....Is this
possible...

Thanks Jen
 
G

Guest

Hi, Jennifer.

Assuming the two forms share a common field that is the primary key of the
record, the following code in a command button OnClick event procedure will
open the second form to the same record and close the first form:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "YourSecondForm"

stLinkCriteria = "[YourPrimaryKey]=" & Me![ControlOnCurrentFormWithPrimaryKey]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.Close

Hope that helps.
Sprinks
 

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