View Full Version : Exit Forms


benc
01-07-2002, 12:14 AM
After creating a command button to open another form. Upon click to open the new form how can i get the current form to close. Can anyone help Thanks.

Graham T
01-07-2002, 02:27 AM
Private Sub "YourControlName"_Click()

DoCmd.Close acForm, "[frmYourForm]", acSaveYes
'Close Form
'acSaveYes saves any changes to the form without prompting


DoCmd.OpenForm "[frmYourFormToBeOpened]"

End Sub

benc
01-07-2002, 04:16 AM
Hi thanks for helping me but i dont seem to be able to get it working. This is the code as i understand it:

Dim userform As String
Dim stLinkCriteria1 As String

userform = "User Form"
DoCmd.Close acForm, "[username]",acSaveYes
DoCmd.openform userform, , , stLinkCriteria1

End Sub

Sorry if it something silly that i have done wrong, i have only been doing VB for a couple of weeks.

Thanks

Ben

Pat Hartman
01-07-2002, 04:48 AM
You have not supplied a value for stLinkCriteria1.

benc
01-08-2002, 01:48 AM
I used the wizard to do the command to open the form so its just something that has put in. in doesnt make any affect as it still opens the form. The bit that i am struggling on is getting the form that it is currently in to close after opening the new form. Does this help?

Thanks

BEN

LiamIngram
01-08-2002, 03:31 AM
Someone tell me if im wrong by doing this but I quite simply made a macro that closes form then opens new one.

Liam