Open a child form button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello
I was wondering if its possible to creat a button into a form that leads to
another form and close the mother form the same time.
thanks
 
You can make a button using the wizard to open a form which is probably the
easiest way of generating the button. If you do that you will see similar
code as below with the exception of the DoCmd.Close line which will close
your mother form for you after opening the child form.

Dim stDocName As String
Dim stLinkCriteria As String

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

DoCmd.GoToRecord acForm, "YourChildFormName", acNewRec 'you may need to
do something about which record to display

DoCmd.Close acForm, "YourMotherFormName", acSaveYes 'Save can be removed
if not required

I have seperated the lines because of text wrapping

hth Let me know how you get on?

Mike B

--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.
 
thanks Mike

MikeJohnB said:
You can make a button using the wizard to open a form which is probably the
easiest way of generating the button. If you do that you will see similar
code as below with the exception of the DoCmd.Close line which will close
your mother form for you after opening the child form.

Dim stDocName As String
Dim stLinkCriteria As String

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

DoCmd.GoToRecord acForm, "YourChildFormName", acNewRec 'you may need to
do something about which record to display

DoCmd.Close acForm, "YourMotherFormName", acSaveYes 'Save can be removed
if not required

I have seperated the lines because of text wrapping

hth Let me know how you get on?

Mike B

--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.
 

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

Back
Top