Adding VBA code to a form

S

sheena

I have created a form using a wizard.

the code that appears looks like this


Private Sub Enter_pg1_Click()
On Error GoTo Err_Enter_pg1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Data_Capture_step_2"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Enter_pg1_Click:
Exit Sub
Err_Enter_pg1_Click:
MsgBox Err.Description
Resume Exit_Enter_pg1_Click
End Sub
Private Sub Exit_pg_1_Click()
On Error GoTo Err_Exit_pg_1_Click


DoCmd.Close

Exit_Exit_pg_1_Click:
Exit Sub

Err_Exit_pg_1_Click:
MsgBox Err.Description
Resume Exit_Exit_pg_1_Click
End Sub


i would like to add code so that when the user clicks on the enter button it
opens Data_Capture_Page 2 but it automatically closes Data_Capture_Page_1.

i believe in order to do this the code should read something like

Docmd.close acform, "Data_Capture_Page_1

However i dont know where this code should be inserted in the coding above
or even if this piece of code is right.

is anyone able to help please
Thank you
Sheena
 
A

Arvin Meyer [MVP]

Add your code right after the line:

DoCmd.OpenForm stDocName, , , stLinkCriteria
 

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