473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Tab Control

Hello All,
I could really use some serious help with this one...
I have a form that has a tab control with 3 pages. Page(0) is Tasks,
Page(1) is SubTasks, and Page(2) is Elements. Page (1) is a subform of
page (0); linked with TaskID and page (2) is a subform of page (1);
linked with SubtaskID. I want to be able to have multiple subtasks for
some tasks; and multiple elements for some subtasks. The relationship
has been set accordingly; however when I try to add a second
corresponding record I am not able to retain the linked ID. For
instance, i have a task and want to make 2 subtasks. I can get the
first subtasks linked to the task but when I navigate to a new subtask
record, the taskId becomes 0 (not the previous/correct value). I tried
using the following code but it doesn't work.

Private Sub cmdAddNewSubtask_Click()
On Error GoTo Err_cmdAddNewSubtask_Click

DoCmd.GoToRecord , , acNewRec
Forms!Tasks!SubTasks1!TaskID = Me.TaskID

Exit_cmdAddNewSubtask_Click:
Exit Sub

Err_cmdAddNewSubtask_Click:
MsgBox Err.Description
Resume Exit_cmdAddNewSubtask_Click

End Sub

Jun 1 '06 #1
2 4934
Presumably you have 3 tables:
- Task, with TaskID primary key.
- SubTask, with SubTaskID primary key, and TaskID foreign key.
- Element, with ElementID primary key, and SubTaskID foreign key.

Now you have a form that is bound to the Task table.
The fields of this table appear on page 0 of the tab control.

On page 1 of the tab control, you have a subform bound to the SubTask table.
The LinkMasterFields and LinkChildFields properties of the subform control
connect it correctly, based on the TaskID in the main form, and the TaskID
in the subform.

On page 2 of the tab control, you are trying to put another subform bound to
the Element table. There is no SubTaskID on the main form, so you cannot set
the LinkMasterFields property, and so this subform doesn't work.

It that's what is going on, add a text box to the main form, and give it
these properties:
Name txtSubTaskID
Control Source =[SubTask].[Form]![SubTaskID]
Format General Number
Visible No

You can now set the 2nd subform's LinkMasterFields property to:
txtSubTaskID
and set its LinkChildFields to:
SubTaskID

In your code, the line:
Forms!Tasks!SubTasks1!TaskID = Me.TaskID
is unnecessary. If you have the LinkMasterFields/LinkChildFields properties
of the subform control set correctly, the subform will automatically inherit
the value from the parent form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dBNovice" <lu*****@hotmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Hello All,
I could really use some serious help with this one...
I have a form that has a tab control with 3 pages. Page(0) is Tasks,
Page(1) is SubTasks, and Page(2) is Elements. Page (1) is a subform of
page (0); linked with TaskID and page (2) is a subform of page (1);
linked with SubtaskID. I want to be able to have multiple subtasks for
some tasks; and multiple elements for some subtasks. The relationship
has been set accordingly; however when I try to add a second
corresponding record I am not able to retain the linked ID. For
instance, i have a task and want to make 2 subtasks. I can get the
first subtasks linked to the task but when I navigate to a new subtask
record, the taskId becomes 0 (not the previous/correct value). I tried
using the following code but it doesn't work.

Private Sub cmdAddNewSubtask_Click()
On Error GoTo Err_cmdAddNewSubtask_Click

DoCmd.GoToRecord , , acNewRec
Forms!Tasks!SubTasks1!TaskID = Me.TaskID

Exit_cmdAddNewSubtask_Click:
Exit Sub

Err_cmdAddNewSubtask_Click:
MsgBox Err.Description
Resume Exit_cmdAddNewSubtask_Click

End Sub

Jun 2 '06 #2
The code doesn't work; I get the "#Name?" error. The main form is
bound to the Task and Subtask tables. If I bound it only to the Task
table, I get a request for parameter Subtasks.SubtaskId. If I bound
the form to all 3 tables, I'm not able to add new records. I am still
not able to add multiple subtasks to one task. The new record comes
up; but the taskId for the new record is not the same (it is 0). I get
the following error when I try to add a 2nd subtask to correspond with
the previous task: "The LinkMasterFields property setting has produced
this error: 'The object doesn't contain the Automation object 'TaskID."
Allen Browne wrote:
Presumably you have 3 tables:
- Task, with TaskID primary key.
- SubTask, with SubTaskID primary key, and TaskID foreign key.
- Element, with ElementID primary key, and SubTaskID foreign key.

Now you have a form that is bound to the Task table.
The fields of this table appear on page 0 of the tab control.

On page 1 of the tab control, you have a subform bound to the SubTask table.
The LinkMasterFields and LinkChildFields properties of the subform control
connect it correctly, based on the TaskID in the main form, and the TaskID
in the subform.

On page 2 of the tab control, you are trying to put another subform bound to
the Element table. There is no SubTaskID on the main form, so you cannot set
the LinkMasterFields property, and so this subform doesn't work.

It that's what is going on, add a text box to the main form, and give it
these properties:
Name txtSubTaskID
Control Source =[SubTask].[Form]![SubTaskID]
Format General Number
Visible No

You can now set the 2nd subform's LinkMasterFields property to:
txtSubTaskID
and set its LinkChildFields to:
SubTaskID

In your code, the line:
Forms!Tasks!SubTasks1!TaskID = Me.TaskID
is unnecessary. If you have the LinkMasterFields/LinkChildFields properties
of the subform control set correctly, the subform will automatically inherit
the value from the parent form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"dBNovice" <lu*****@hotmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
Hello All,
I could really use some serious help with this one...
I have a form that has a tab control with 3 pages. Page(0) is Tasks,
Page(1) is SubTasks, and Page(2) is Elements. Page (1) is a subform of
page (0); linked with TaskID and page (2) is a subform of page (1);
linked with SubtaskID. I want to be able to have multiple subtasks for
some tasks; and multiple elements for some subtasks. The relationship
has been set accordingly; however when I try to add a second
corresponding record I am not able to retain the linked ID. For
instance, i have a task and want to make 2 subtasks. I can get the
first subtasks linked to the task but when I navigate to a new subtask
record, the taskId becomes 0 (not the previous/correct value). I tried
using the following code but it doesn't work.

Private Sub cmdAddNewSubtask_Click()
On Error GoTo Err_cmdAddNewSubtask_Click

DoCmd.GoToRecord , , acNewRec
Forms!Tasks!SubTasks1!TaskID = Me.TaskID

Exit_cmdAddNewSubtask_Click:
Exit Sub

Err_cmdAddNewSubtask_Click:
MsgBox Err.Description
Resume Exit_cmdAddNewSubtask_Click

End Sub


Jun 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
4
by: gsb58 | last post by:
Hi! On a form I have a calendar. The form is rezised to 1024x768 (Don't worry - this is a training case) when loaded. Now I want to center the calendar on the form so that its edges are...
5
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.