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_Cl ick()
On Error GoTo Err_ViewSubtask s_Click
Me.Subtasks.Vis ible = True
Me.Title.SetFoc us
Me!Subtasks.For m.Controls("Ele ments").Visible = False
Exit_ViewSubtas ks_Click:
Exit Sub
Err_ViewSubtask s_Click:
MsgBox Err.Description
Resume Exit_ViewSubtas ks_Click
End Sub
Private Sub ViewTasks_Click ()
On Error GoTo Err_ViewTasks_C lick
Me!Title.SetFoc us
Me!Subtasks.Vis ible = False
Exit_ViewTasks_ Click:
Exit Sub
Err_ViewTasks_C lick:
MsgBox Err.Description
Resume Exit_ViewTasks_ Click
End Sub
Private Sub ViewElements_Cl ick()
On Error GoTo ErrHandler
Me!Subtasks.For m.Controls("Ele ments").Visible = True
Me!Title.SetFoc us
Exit Sub
ErrHandler:
MsgBox "Error in ViewElements_Cl ick( ) 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*****@hotmai l.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.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_Cl ick()
On Error GoTo Err_ViewSubtask s_Click
Me.SubTasks.Vis ible = True
Me.Title.SetFoc us
Exit_ViewSubtas ks_Click:
Exit Sub
Err_ViewSubtask s_Click:
MsgBox Err.Description
Resume Exit_ViewSubtas ks_Click
End Sub
Subform Subtask's Title event when title has focus:
Private Sub Title_GotFocus( )
Forms!tasks!Sub Tasks!Elements. Visible = False
End Sub
From sub-subform, Element to Main form, Task:
Private Sub ViewTasks_Click ()
On Error GoTo Err_ViewTasks_C lick
Forms!tasks!Tit le.SetFocus
Forms!tasks!Sub Tasks.Visible = False
Exit_ViewTasks_ Click:
Exit Sub
Err_ViewTasks_C lick:
MsgBox Err.Description
Resume Exit_ViewTasks_ Click
End Sub