Adding VBA code to a form

  • Thread starter Thread starter sheena
  • Start date Start date
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
 
Add your code right after the line:

DoCmd.OpenForm stDocName, , , stLinkCriteria
 
Back
Top