Trouble with navigation

J

John Phelan

Form: Main Menu

From the Main Menu you open up the main form, “Program_services†(unbound)
which serves various purposes aside from the fact that it has a single
unbound, first, subform, “frmMain†with two option buttons.

Button #1 opens a Calendar GRID option, which is on the, “frmMain†form;
again is unbound.

Button #2 opens a Registration option, which contains a, second, subform,
“frmStatus†which is bound (tblStatus table)


The code behind the “frmStatus†subform includes the following which works
but only when I use it as the first subform to the, “frmMain†form as a main,
popup, form:

Private Sub Form_AfterUpdate()
RequeryAllCtls
*Forms!frmMain.DrawGrid (The, DrawGrid is located on the first subform,
“frmMainâ€, and not on
the “frmStatusâ€.)
End Sub

Also, the frmStatus form also contains 4 synchronized combo boxes; all four
boxes synch together correctly as designed.


Problem:

However, once I synchronize all four combo boxes to call up information to
include in the current record, I try to navigate to another record. When I
try to use the navigation button to move from record to record, when the
“frmMain†form is used as the first sub form to, “Program_Services†(main
form), I get the following error pointing to code behind the form,
“frmStatusâ€:

*Run-time error '2450':

Microsoft Office Access can't find the form 'frmMain' referred to in a
macro expression or Visual Basic code.

My thinking was that frmMain cannot be found until the main form
“program_services†was found. I tried the follow combinations; nothing works:

Forms![program_services].frmMain.DrawGrid
Forms![program_services]![frmMain].DrawGrid
Forms!program_services!frmMain.DrawGrid
Forms!program_services!frmMain.DrawGrid
Forms!program_services.frmMain.DrawGrid

John
 
M

MacDermott

Forms which are opened inside subform controls are not members of the Forms
collection.
Therefore if frmMain is opened as a main form, it can be addressed as
Forms!frmMain, but if it's inside a subform, it cannot.

Here's one way of addressing it from the frmStatus subform (assuming the
subform control on Program_services is also named "frmMain":
Me.Parent.frmMain.Form.DrawGrid
 
J

John Phelan

I changed the code as follows as you suggested:

Private Sub Form_AfterUpdate()
RequeryAllCtls
Me.Parent.frmMain.Form.DrawGrid

After running the steps again, I got the following error:

Run-time error '2465':

Application-defined or object-defined error

John



MacDermott said:
Forms which are opened inside subform controls are not members of the Forms
collection.
Therefore if frmMain is opened as a main form, it can be addressed as
Forms!frmMain, but if it's inside a subform, it cannot.

Here's one way of addressing it from the frmStatus subform (assuming the
subform control on Program_services is also named "frmMain":
Me.Parent.frmMain.Form.DrawGrid


John Phelan said:
Form: Main Menu

From the Main Menu you open up the main form, "Program_services" (unbound)
which serves various purposes aside from the fact that it has a single
unbound, first, subform, "frmMain" with two option buttons.

Button #1 opens a Calendar GRID option, which is on the, "frmMain" form;
again is unbound.

Button #2 opens a Registration option, which contains a, second, subform,
"frmStatus" which is bound (tblStatus table)


The code behind the "frmStatus" subform includes the following which works
but only when I use it as the first subform to the, "frmMain" form as a main,
popup, form:

Private Sub Form_AfterUpdate()
RequeryAllCtls
*Forms!frmMain.DrawGrid (The, DrawGrid is located on the first subform,
"frmMain", and not on
the "frmStatus".)
End Sub

Also, the frmStatus form also contains 4 synchronized combo boxes; all four
boxes synch together correctly as designed.


Problem:

However, once I synchronize all four combo boxes to call up information to
include in the current record, I try to navigate to another record. When I
try to use the navigation button to move from record to record, when the
"frmMain" form is used as the first sub form to, "Program_Services" (main
form), I get the following error pointing to code behind the form,
"frmStatus":

*Run-time error '2450':

Microsoft Office Access can't find the form 'frmMain' referred to in a
macro expression or Visual Basic code.

My thinking was that frmMain cannot be found until the main form
"program_services" was found. I tried the follow combinations; nothing works:

Forms![program_services].frmMain.DrawGrid
Forms![program_services]![frmMain].DrawGrid
Forms!program_services!frmMain.DrawGrid
Forms!program_services!frmMain.DrawGrid
Forms!program_services.frmMain.DrawGrid

John
 
J

John Phelan

You got me thinking about what you said about mainforms and subform controls.
I never heard or read that before. So I got rid of the,
"Program_Services". I took the information off the form first and moved it
to the subform, "frmMain". I then redesignd the form to look like it was
still on the mainform as a subform, even though it's not. For continuity
purposes; its design/layout remains consistant with other areas of the
application. Oh yea, the navigation now works!

Thanks-a-bunch,
John


MacDermott said:
Forms which are opened inside subform controls are not members of the Forms
collection.
Therefore if frmMain is opened as a main form, it can be addressed as
Forms!frmMain, but if it's inside a subform, it cannot.

Here's one way of addressing it from the frmStatus subform (assuming the
subform control on Program_services is also named "frmMain":
Me.Parent.frmMain.Form.DrawGrid


John Phelan said:
Form: Main Menu

From the Main Menu you open up the main form, "Program_services" (unbound)
which serves various purposes aside from the fact that it has a single
unbound, first, subform, "frmMain" with two option buttons.

Button #1 opens a Calendar GRID option, which is on the, "frmMain" form;
again is unbound.

Button #2 opens a Registration option, which contains a, second, subform,
"frmStatus" which is bound (tblStatus table)


The code behind the "frmStatus" subform includes the following which works
but only when I use it as the first subform to the, "frmMain" form as a main,
popup, form:

Private Sub Form_AfterUpdate()
RequeryAllCtls
*Forms!frmMain.DrawGrid (The, DrawGrid is located on the first subform,
"frmMain", and not on
the "frmStatus".)
End Sub

Also, the frmStatus form also contains 4 synchronized combo boxes; all four
boxes synch together correctly as designed.


Problem:

However, once I synchronize all four combo boxes to call up information to
include in the current record, I try to navigate to another record. When I
try to use the navigation button to move from record to record, when the
"frmMain" form is used as the first sub form to, "Program_Services" (main
form), I get the following error pointing to code behind the form,
"frmStatus":

*Run-time error '2450':

Microsoft Office Access can't find the form 'frmMain' referred to in a
macro expression or Visual Basic code.

My thinking was that frmMain cannot be found until the main form
"program_services" was found. I tried the follow combinations; nothing works:

Forms![program_services].frmMain.DrawGrid
Forms![program_services]![frmMain].DrawGrid
Forms!program_services!frmMain.DrawGrid
Forms!program_services!frmMain.DrawGrid
Forms!program_services.frmMain.DrawGrid

John
 

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

Top