472,800 Members | 2,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,800 software developers and data experts.

Navigating from Main form to subform to sub-subform

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
1 3330
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: andre | last post by:
HI, I’m learning C# and already know VB .Net. I noticed that C# you have a Static Void Main () (entry point of the app). Well that got me thinking, I was told that VB.net removed “The...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
1
by: Richard Hollenbeck | last post by:
I have a main form for entering students' grades. The main form indicates which activity I will be entering. The sub form on the right contains the actual score for the activity. It is based...
1
by: Lerp | last post by:
Hi all, I have a dataset made up of 3 tables that is bound to a datalist. On the itemdataBound event I call a sub that grabs a value (an id value) from the current row being outputted, queries...
5
by: Roy Lawson | last post by:
I am having no problems connecting to a DB, creating a DataAdapter, and creating a dataset...and connecting to the data. Using the builtin data objects to do all this. My only problem now is...
4
by: Charles Law | last post by:
Hi guys. I have two threads: a main thread and a background thread. Lots of stuff happens in the background thread that means I have to update several (lots) of controls on a form. It is...
1
by: VictorT | last post by:
Hi All, I am trying to create a simple Windows form that lists a users' data one user at a time with the usual "Next" & "Previous" buttons. Upon loading the form, I am able to populate all...
8
by: koorb | last post by:
I am starting a program from a module with the Sub main procedure and I want it to display two forms for the program's interface, but when I run the program both forms just open and then program...
0
by: Ohad Weiss | last post by:
Hi all, I've once asked about that topic. but didn't get an answer. I have a dataset based on 4 tables, which have relation between them. The main table presented to the user on textboxes...
5
by: Thelma Roslyn Lubkin | last post by:
I am still having trouble trying to use a popup form to allow user to set filters for the main form. The main form is based on a single table. The popup contains 5 listboxes, so the user can...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.