View Single Post
  #2  
Old February 24th, 2006, 04:38 AM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Opening new form and closing the present one?

Try something like:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, Me.Name

--
Duane Hookom
MS Access MVP
--

"elli" wrote in message
...
Good morning!
I made a form with command button that opens a new form. Can I put a piece
of code to close the first form in this code too? If so what piece of code
and where exactly to put it?

-elli-

Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

Dim stDocName As String
Dim stLinkCriteria As String

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

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub