Close Parent Form (1 Viewer)

cos

Registered User.
Local time
Today, 13:07
Joined
Jul 13, 2012
Messages
81
so, i went through my wizzard on creating a form, where i use two tables, and i had chosen the option to have "linked forms" rather than "form with subform(s)".

When i click on the button to open the child form, i want the parent form to close...

any ideas at all?

cuz i tried almost everything.. i inputed macro on the available slots (such as On Open event) so that the form would close... didn't work. tried to investigate how i can somehow squeeze in some code so that it would carry out the procedure and close( DoCmd. Close)... didn't work.

however, please consider that On Load event in the child form, i am pulling out info from the parent form! and if i was to run macro CloseWindow on open, then the form confuses it self and doesn't know where to find the data..

see if you can think of somethin... cuz im out of ideas =/
 

bob fitz

AWF VIP
Local time
Today, 13:07
Joined
May 23, 2011
Messages
4,726
What is the name of the first form that you want to close?

Can you show us the code in the On Load event of the second form?
 

cos

Registered User.
Local time
Today, 13:07
Joined
Jul 13, 2012
Messages
81
Code:
Sub Form_Load()
On Error GoTo Form_Load_Err

    If ParentFormIsOpen() Then Forms![01_AddShop]!ToggleLink = True


Form_Load_Exit:
    Exit Sub

Form_Load_Err:
    MsgBox Error$
    Resume Form_Load_Exit

End Sub
 

bob fitz

AWF VIP
Local time
Today, 13:07
Joined
May 23, 2011
Messages
4,726
Try:
Code:
Sub Form_Load()
On Error GoTo Form_Load_Err

    If ParentFormIsOpen() Then Forms![01_AddShop]!ToggleLink = True
    
    DoCmd.Close acForm, "[COLOR=red]NameOfFormToClose[/COLOR]"
   
Form_Load_Exit:
    Exit Sub

Form_Load_Err:
    MsgBox Error$
    Resume Form_Load_Exit

End Sub
 

cos

Registered User.
Local time
Today, 13:07
Joined
Jul 13, 2012
Messages
81
nop.. not closing =/

seems like a standard task, yet flipping impossible cuz access chooses to be an idiot
 

bob fitz

AWF VIP
Local time
Today, 13:07
Joined
May 23, 2011
Messages
4,726
In the line of code:
DoCmd.Close acForm, "NameOfFormToClose"
Did you replace NameOfFormToClose with the actual name of your form?
 

cos

Registered User.
Local time
Today, 13:07
Joined
Jul 13, 2012
Messages
81
-.-


yes.. yes i did.. still not working my friend..
 

bob fitz

AWF VIP
Local time
Today, 13:07
Joined
May 23, 2011
Messages
4,726
-.-


yes.. yes i did.. still not working my friend..
Just thought I'd ask because some times we miss the obvious.:)

Have you tried setting a breakpoint and stepping through the code at runtime to confirm that all the code runs.
 

cos

Registered User.
Local time
Today, 13:07
Joined
Jul 13, 2012
Messages
81
still not working mate.. any other ideas or thoughts on how to approach this?

:(
 

bob fitz

AWF VIP
Local time
Today, 13:07
Joined
May 23, 2011
Messages
4,726
If you have set a breakpoint and stepped through the code at runtime and the form is still not closing, check and double check the spelling of the form name. You don't get any error message if it is spelt wrong but obviously it won't close the form.
 

cos

Registered User.
Local time
Today, 13:07
Joined
Jul 13, 2012
Messages
81
For god sake.. if only we had thought of that earlier =/ spent the whole day looking for solutions..
Thought I should thank the best post :eek:

thanks, a lot bud.. it seems to work like clockwork now :)
 

bob fitz

AWF VIP
Local time
Today, 13:07
Joined
May 23, 2011
Messages
4,726
For god sake.. if only we had thought of that earlier =/ spent the whole day looking for solutions..
Thought I should thank the best post :eek:

thanks, a lot bud.. it seems to work like clockwork now :)
You're welcome. I'm just glad we got there.:) Good luck with your project.
 

Users who are viewing this thread

Top Bottom