473,386 Members | 1,973 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,386 software developers and data experts.

access subform key field only intermittently populating subsubform

Help

I built a form/subform/subsubform setup using the access forms
wizard. I have a table1 = parent, table2 = child, table3 =
(grandchild?). There will be multiple records in table2 that tie to
table1, and multiple records in table 3 that tie to table2. Both on
"1 to many" joins.

Each of the forms are bound to the fields in the respective tables.
The subform & subsubform are datasheet view. When I enter any data, I
do it through the main form only, which means I see all 3 forms on the
screen. I actually enter the data into all 3 forms [main, sub, &
subsub.]

The join between tables 1 & 2 is an autonumber index in table 1 and a
foreign number field in table2. This join seems to work fine. Also,
there is an autonumber primary index field in table 2 that joins to a
foreign number field in table 3. This join also seemed to behave as
expected for several weeks in testing.

The problem: Now when I add a record into this subsubform, sometimes
it works fine, but very often i do not get the number field in table 3
that would tie to the autonumberID field in table2.

I have deleted my provisional formatting and have added the autonumber
and foreign fields to each of the sub & subsub forms.

What have I done? Any help would be much appreciated.

Don

Jan 29 '07 #1
4 2634
Don, you say that both subforms are in datasheet view?'
If subform1 is in datasheet view, it cannot have a subform.
Therefore I have to assume that subform1 and subform2 are both sitting on
the main form. This may affect the way it picks up the value for its foreign
key field.

Suggestions.
1. Open Table3 in design view, and select the foreign key field.
If you see a zero beside the Default Value property, delete it.
Set the Required property to Yes for the foreign key field.
This will prevent Access saving the record when the key is not picked up,
and it will notify you which will help your debugging. (I assume you already
have a relationship between these 2 tables, with Referential Integrity
enforced.)

2. Open the main form in design view. Right-click the lower-level subform,
and choose Properties. On the Data tab of the Properties box, what do you
have for LinkMasterFields and LinkChildFields? If LinkMasterFields is an
expression such as:
[Forms].[MyMainForm].[Sub1].[Form].[ID]
then you might try changing it.
Add a text box to the main form, with properties like this:
Control Source [Sub1].[Form].[ID]
Format General Number
Then set LinkMasterFields to the name of this text box.

3. If none of this works, you can use the BeforeInsert event of the lower
level subform to either read and manually assign the foreign key field
value, or cancel the insert.

--
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.

"Don Do" <bi************@gmail.comwrote in message
news:11**********************@v45g2000cwv.googlegr oups.com...
Help

I built a form/subform/subsubform setup using the access forms
wizard. I have a table1 = parent, table2 = child, table3 =
(grandchild?). There will be multiple records in table2 that tie to
table1, and multiple records in table 3 that tie to table2. Both on
"1 to many" joins.

Each of the forms are bound to the fields in the respective tables.
The subform & subsubform are datasheet view. When I enter any data, I
do it through the main form only, which means I see all 3 forms on the
screen. I actually enter the data into all 3 forms [main, sub, &
subsub.]

The join between tables 1 & 2 is an autonumber index in table 1 and a
foreign number field in table2. This join seems to work fine. Also,
there is an autonumber primary index field in table 2 that joins to a
foreign number field in table 3. This join also seemed to behave as
expected for several weeks in testing.

The problem: Now when I add a record into this subsubform, sometimes
it works fine, but very often i do not get the number field in table 3
that would tie to the autonumberID field in table2.

I have deleted my provisional formatting and have added the autonumber
and foreign fields to each of the sub & subsub forms.

What have I done? Any help would be much appreciated.

Don
Jan 30 '07 #2
Don Do wrote:
>I built a form/subform/subsubform setup using the access forms
wizard. I have a table1 = parent, table2 = child, table3 =
(grandchild?). There will be multiple records in table2 that tie to
table1, and multiple records in table 3 that tie to table2. Both on
"1 to many" joins.

Each of the forms are bound to the fields in the respective tables.
The subform & subsubform are datasheet view. When I enter any data, I
do it through the main form only, which means I see all 3 forms on the
screen. I actually enter the data into all 3 forms [main, sub, &
subsub.]

The join between tables 1 & 2 is an autonumber index in table 1 and a
foreign number field in table2. This join seems to work fine. Also,
there is an autonumber primary index field in table 2 that joins to a
foreign number field in table 3. This join also seemed to behave as
expected for several weeks in testing.

The problem: Now when I add a record into this subsubform, sometimes
it works fine, but very often i do not get the number field in table 3
that would tie to the autonumberID field in table2.

Since a datasheet (or continuous) form can not have a
subform, I assume that both subforms are on the main form.
In this case, the secret is to set the LinkMaster/Child
properties appropriately.

Add a text box (named txtLink) to the main form. Then add a
line of code to the subform's Current event:
Parent.txtLink = Me.pkfield

Set subsubform's Link Master Fields property to txtLink and
the Link Child Fields property to table3's foreign key.

--
Marsh
Jan 30 '07 #3
Allen & Marsh,

Thanks for your posts. I did Allen's steps 1 & 2, and the file
settled down.

Problem now is that when I do a search on a mainform item, I find many
instances of the same record. I have to keep paging through the found
items to get to the second mainform record. It seems that my search
now finds a mainform record for each level 2 index number.

So what is the trick I'm missing now?

Thanks again.

Don

Mar 20 '07 #4
So the main form's RecordSource is an INNER JOIN query? And so it contains
the main record multiple times if there are mulitple related matches?

If that is the case, you could change the main form's RecordSource to a
query that does not include the related table(s). Instead use a subquery in
the WHERE clause to choose the records that have a match in the related
table.

For details, see:
Subquery Basics: Filters and Searches
at:
http://allenbrowne.com/subquery-01.html#Search

--
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.

"Don Do" <bi************@gmail.comwrote in message
news:11**********************@l75g2000hse.googlegr oups.com...
Allen & Marsh,

Thanks for your posts. I did Allen's steps 1 & 2, and the file
settled down.

Problem now is that when I do a search on a mainform item, I find many
instances of the same record. I have to keep paging through the found
items to get to the second mainform record. It seems that my search
now finds a mainform record for each level 2 index number.

So what is the trick I'm missing now?

Thanks again.

Don
Mar 20 '07 #5

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

Similar topics

4
by: ajikoe | last post by:
Hello, I'm new to python, How can I access private field in python. thanks
2
by: Vincent Lau | last post by:
Hello, I'm new on ASP and Access. I stored several lines of information in a Access memo field. I use follow ASP response.write statement to display contain of the memo field. Response.Write...
2
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value...
6
by: Matt | last post by:
I'm having difficulty with trying to update a Access memo field through an SQL statement where the value I'm trying to pass is longer than 255 characters. The field is being truncated. I'm using...
3
by: M. Noroozi Eghbali | last post by:
Hi All, I used the below code to get the information from a MS Access database file: ---------------------------------------------------- bdpConnection1.Open();...
3
by: zlf | last post by:
Hi, I am trying to access private field by code below. But it runs with error. Please tell me what's the problem or any method that may allow me to access private field. Thank you class Love...
5
by: sklett | last post by:
I'm not real experienced with asp.net so this may be obvious. I've got a situation where some of my client side javascript is causing my posted form's controls to lose their values. In other...
0
by: Gordon Padwick | last post by:
A form contains controls, one or more of which can be other forms. A form that contains another form is known as a main form. A form contained by a main form is known as a subform. A subform itself...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.