By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Navigating from Main form to subform to sub-subform

P: n/a
Please help! I have 3 forms: Task, Subtask, Elements.
Elements is a subform of Subtask and Subtask is a subform of Task. I
am able to navigate from Task to Subform to Element and from Element to
Subtask to Task by pressing a button that makes each subform
invisible/visible.
The problem exists when I try to navigate from Element to Task to
Subtask. Sub-subform Element will become invisible and show Task but
when I press the button to go from Task to Subtask it opens the subform
but Element is still visible over the Subtask form. Below is the code
I am using....
From Main form, Task to subform, Subtask: Private Sub ViewSubtasks_Click()
On Error GoTo Err_ViewSubtasks_Click
Me.SubTasks.Visible = True
Me.Title.SetFocus
Exit_ViewSubtasks_Click:
Exit Sub

Err_ViewSubtasks_Click:
MsgBox Err.Description
Resume Exit_ViewSubtasks_Click
End Sub

Subform Subtask's Title event when title has focus:
Private Sub Title_GotFocus()
Forms!tasks!SubTasks!Elements.Visible = False
End Sub
From sub-subform, Element to Main form, Task:

Private Sub ViewTasks_Click()
On Error GoTo Err_ViewTasks_Click
Forms!tasks!Title.SetFocus
Forms!tasks!SubTasks.Visible = False

Exit_ViewTasks_Click:
Exit Sub

Err_ViewTasks_Click:
MsgBox Err.Description
Resume Exit_ViewTasks_Click
End Sub

Apr 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi.

Hundreds of people have read your question and might have answered it, but
they skipped it because it's very unclear. You've left out information, you
have typos, and even when the typos are fixed, the code you offered doesn't
do what your description says it does.

Therefore, I'm going to make a bunch of assumptions and offer you some code
that I think does what you intend yours to do. First, make a copy of your
main form, Task, and name this new form frmTask. Open up this new form's
module, delete the code you have (at least the part that you posted here
yesterday) and replace it by pasting the following code into it:

' * * * * Start Code * * * *

Private Sub ViewSubtasks_Click()

On Error GoTo Err_ViewSubtasks_Click

Me.Subtasks.Visible = True
Me.Title.SetFocus
Me!Subtasks.Form.Controls("Elements").Visible = False

Exit_ViewSubtasks_Click:
Exit Sub

Err_ViewSubtasks_Click:
MsgBox Err.Description
Resume Exit_ViewSubtasks_Click
End Sub
Private Sub ViewTasks_Click()

On Error GoTo Err_ViewTasks_Click

Me!Title.SetFocus
Me!Subtasks.Visible = False

Exit_ViewTasks_Click:
Exit Sub

Err_ViewTasks_Click:
MsgBox Err.Description
Resume Exit_ViewTasks_Click
End Sub
Private Sub ViewElements_Click()

On Error GoTo ErrHandler

Me!Subtasks.Form.Controls("Elements").Visible = True
Me!Title.SetFocus

Exit Sub

ErrHandler:

MsgBox "Error in ViewElements_Click( ) in " & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub

' * * * * End Code * * * *

Make sure that I've spelled your subform controls and three button names
correctly, then save and compile the code. Open this new form in Form View
and test it. Does it work the way you intended? If not, please post back
with a discription of what you'd like it to do and what's happening instead.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"dBNovice" <lu*****@hotmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Please help! I have 3 forms: Task, Subtask, Elements.
Elements is a subform of Subtask and Subtask is a subform of Task. I
am able to navigate from Task to Subform to Element and from Element to
Subtask to Task by pressing a button that makes each subform
invisible/visible.
The problem exists when I try to navigate from Element to Task to
Subtask. Sub-subform Element will become invisible and show Task but
when I press the button to go from Task to Subtask it opens the subform
but Element is still visible over the Subtask form. Below is the code
I am using....
From Main form, Task to subform, Subtask:

Private Sub ViewSubtasks_Click()
On Error GoTo Err_ViewSubtasks_Click
Me.SubTasks.Visible = True
Me.Title.SetFocus
Exit_ViewSubtasks_Click:
Exit Sub

Err_ViewSubtasks_Click:
MsgBox Err.Description
Resume Exit_ViewSubtasks_Click
End Sub

Subform Subtask's Title event when title has focus:
Private Sub Title_GotFocus()
Forms!tasks!SubTasks!Elements.Visible = False
End Sub
From sub-subform, Element to Main form, Task:

Private Sub ViewTasks_Click()
On Error GoTo Err_ViewTasks_Click
Forms!tasks!Title.SetFocus
Forms!tasks!SubTasks.Visible = False

Exit_ViewTasks_Click:
Exit Sub

Err_ViewTasks_Click:
MsgBox Err.Description
Resume Exit_ViewTasks_Click
End Sub

Apr 23 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.