Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close the Startup form and Open another form, 1

Status
Not open for further replies.

molly

Technical User
Jul 17, 2000
219
0
0
US
I have the following On Click data in my frmStartup (my main menu). I get a VBA error message that "compile error: method or data member not found". The line is grayed out where it says Me.frmStartup on the close line mid way down. Here is Part 1 of 2.

--------------------------------------
Private Sub cmdStartUp_Click()

On Error GoTo Err_cmdStartUp_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMain"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.CLOSE acForm, Me.frmStartUp

Exit_cmdStartUp_Click:
Exit Sub

Err_cmdStartUp_Click:
MsgBox Err.Description
Resume Exit_cmdStartUp_Click

End Sub
---------------------------

So i cannot close frmStartup and open up frmMain.


Here is Part 2 of 2.
I next have a Close button on frmMain in the On Click which seems to work. I only note it for informational reasons.

----------------------------------------
Private Sub cmdClose_Click()

On Error GoTo Err_cmdClose_Click

If Me.Dirty Then
Me.Dirty = False
End If

DoCmd.CLOSE

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

DoCmd.Maximize
DoCmd.OpenForm "frmStartup"

End Sub
-------------------------------------

I learned about the me.dirty today from a book by Phil Mitchell. He refers to an undocumented Access error which a friend of mine encountered. He lost 100 records because of a simplistic close button and also clicking on open forms without getting off his current form and allowing it to save.

So Mitchell suggests the Dirty method above. So this is why i am cleaning up my close buttons.

But I need part 1 to get fixed when i want to close the frmStartup.
thanks alot.
Molly

 
Replace this:
DoCmd.CLOSE acForm, Me.frmStartUp
with either this:
DoCmd.CLOSE acForm, Me.Name
or this:
DoCmd.CLOSE acForm, "frmStartUp"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV: thanks alot. that worked. I used your second choice of DoCmd.CLOSE acForm, "frmStartUp" .

FYI, here is what I have in the 2nd forms Close button that brings me back to the frmStartup. It works. I only note it here for any readers. If you see an improvement, give a yell.


Then in the second form, called frmMain, used this in the Close Button In the On Click event:

Private Sub cmdClose_Click()

On Error GoTo Err_cmdClose_Click

If Me.Dirty Then
Me.Dirty = False
End If

DoCmd.CLOSE

DoCmd.OpenForm "frmStartup"

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

DoCmd.Maximize

End Sub
-----------------------

So now when i click on a frmStartup button to get to another form, the frmStartup closes up and i get the 2nd form called frmMain. The reverse is true too. When i click on my frmMain Close button, the frmMain closes up and I am back to my frmStartup.

Thanks to PHV advice.
Molly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top