473,418 Members | 2,075 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,418 software developers and data experts.

Subform not loading (I think)

Hi. I have a Main form with a subform that has a subform. I have an
'Add Event' button on the Main Form that issues the following
instruction:

DoCmd.GoToRecord , , acNewRec

If the record being displayed BEFORE the 'Add Event' button is clicked
does not have data to be displayed (no associated linked records) then
when the 'new record' is displayed, the innermost subform looks just
fine (all the controls are there and they are empty).

However, if the record being displayed BEFORE the 'Add Event' button is
clicked does have data to be displayed (there are associated linked
records) then when the 'new record' is displayed, the innermost subform
does not show the empty controls at all.

Any ideas why?

Some additional information:
I have the imbedded subforms 'disabled' (enabled=false) when the new
record is displayed. I want to force the user to fill all the fields in
the Main Form, first. Then I'll enable the subforms when all
prerequisite fields are filled. I haven't coded the 'enabling logic'.
I just have the 'disabling logic' in place.

I am really stuck here and could use some serious help.
Thanks.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
5 3465
The detail section of a form goes completely blank if both these conditions
are met:
(a) There are no records to display, and
(b) No new records can be added.

Condition (a) might be because of the way the recordset if filtered.
Condition (b) might be because the form's AllowAdditions property is set to
No, or because the form is based on a read-only query.

A simpler solution might be to cancel the Before Insert event of the subform
if the main form is at a new record. It's this simple:

Private Sub Form_BeforeInsert(Cancel As Integer)
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Enter the main form record first."
End If
End Sub

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

"Susan Bricker" <sl*****@verizon.net> wrote in message
news:p0***************@news.uswest.net...
Hi. I have a Main form with a subform that has a subform. I have an
'Add Event' button on the Main Form that issues the following
instruction:

DoCmd.GoToRecord , , acNewRec

If the record being displayed BEFORE the 'Add Event' button is clicked
does not have data to be displayed (no associated linked records) then
when the 'new record' is displayed, the innermost subform looks just
fine (all the controls are there and they are empty).

However, if the record being displayed BEFORE the 'Add Event' button is
clicked does have data to be displayed (there are associated linked
records) then when the 'new record' is displayed, the innermost subform
does not show the empty controls at all.

Any ideas why?

Some additional information:
I have the imbedded subforms 'disabled' (enabled=false) when the new
record is displayed. I want to force the user to fill all the fields in
the Main Form, first. Then I'll enable the subforms when all
prerequisite fields are filled. I haven't coded the 'enabling logic'.
I just have the 'disabling logic' in place.

I am really stuck here and could use some serious help.

Nov 13 '05 #2
Allen,

Thank you, so much, for replying to my post. Your solutions sounds just
like what I want. I'll have to "rip" out some code but it certainly
seems much simpler. I'll get back to this post after I give it a try.
Thanks, again.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3
Allen,

I tried the Form_BeforeInsert( ) in the subform. It works as long as no
data has been entered in the Parent form. However, as soon as any data
is entered in the Parent form and the tab key is hit, something happens
(I don't know what) ... and then the subform is "not editable" so I
can't continue to test to make sure that the subform is only available
after all Parent fields are filled. It's as if the AllowAdditions and
AllowEdits properties for the subform have been set to
"Enabled=no/false".

I tried to trace it by setting a breakpoint in the AfterUpdate event of
a field in the Parent form. I hit the breakpoint and then it didn't
step through any more routines ... just went to "end" and the form was
then accessible again (I don't know the right terminology ... hope you
understand). So, it appears that I didn't hit any code that would have
changed the properties listed above.

Any ideas?

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #4
If you enter something into the main form, and then move the cursor into the
subform, Access saves the main form record, and so the main form is no
longer at a new record (i.e. it now has an existing record.)

If you want to prevent the focus moving into the subform until you check the
main form record is ready to save, use the BeforeUpdate event of the main
form to run the check, and cancel that event if the record is not ready to
save.

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

"Susan Bricker" <sl*****@verizon.net> wrote in message
news:CC***************@news.uswest.net...
Allen,

I tried the Form_BeforeInsert( ) in the subform. It works as long as no
data has been entered in the Parent form. However, as soon as any data
is entered in the Parent form and the tab key is hit, something happens
(I don't know what) ... and then the subform is "not editable" so I
can't continue to test to make sure that the subform is only available
after all Parent fields are filled. It's as if the AllowAdditions and
AllowEdits properties for the subform have been set to
"Enabled=no/false".

I tried to trace it by setting a breakpoint in the AfterUpdate event of
a field in the Parent form. I hit the breakpoint and then it didn't
step through any more routines ... just went to "end" and the form was
then accessible again (I don't know the right terminology ... hope you
understand). So, it appears that I didn't hit any code that would have
changed the properties listed above.

Any ideas?

Regards,
SueB

Nov 13 '05 #5
Allen,

Thank you for your suggestions. I'll give it a try.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #6

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

Similar topics

0
by: Joseph J. Egan | last post by:
I am extending an existing Access/VBA app and need to update a subform displayed in continuous view within a containing form. The existing form and subform have worked fine to date with the...
2
by: nic | last post by:
Hi I am currently having problems getting two forms to behave the way I want. I have two tables Student and Application, and their respective forms. (Tables)Student has StudentID (PK) & an...
9
by: PC Datasheet | last post by:
I'm stuck on something that seems should be easy and I need some help. My main form has an option group with five options. My subform chooses from different lists depending on which option is...
1
by: sasan3 | last post by:
I have a main form "topform" contaning "subform1" and "subform2" The goal is: I need to requery subform2 on CURRENT event of subform1, and I need to load subform2 contents based on settings on...
2
by: Bill Stock | last post by:
I have a subform which is causing a 3314 (Field can't contain a null value because required is set to True) error. I solved this problem by trapping it in the before update event. But then I...
7
by: ApexData | last post by:
I am using the following code in my TabControl to manage subform loads. The code assigns the subForms SourceObject. - Do I also need code to DeAssign the SourceObject when leaving the Tab, I'm...
18
by: Robert Jacobs | last post by:
Please advise... I currently have a Mainform (Customers) and a Subform (Service Requests) with a one to many relationship (one customer, many service requests) with a CustomerID that is unique...
1
by: maffonso | last post by:
Hi people, My main form has a subform nested with another subform, both subs work as a subDatasheet. Indeed I keep the mainForm just to put some filters. Whenever I open de MainForm I have no...
3
by: AccessBeetle | last post by:
I have a table called tblLocationInfo which has field like I have a form which has a subform and this subform has all these county, township and quad comboboxes based on the look up tables(ex...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.