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

the dirty form!

Ray
I have a subform which takes one of its fields from the main form,
namely the YearLevel which is from 1 to 8. There is also another field
which returns the year from datePart.

If I select a record from the mainform is automatically creates a
record in the subform table even though I have not enter in the school
marks. This obviously comes from the YearLevel and the defaulted year.

is there a way of preventing this occurring. I only want a record in
the subform once I begin to enter the school marks. Maybe this is
impossible. Perhaps a delete query might help if all the score marks
are still null on closure?

Any ideas anyone? TIA - Ray
Nov 12 '05 #1
1 1925
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You should use the BeforeUpdate event procedure on the subform to get
the values you want from the main form. This way, those values will
only be entered into the subform record when you've entered data in
the subform record & are about to save the record (by moving to
another record in the main form or subform, or closing the main form).

Example of subform's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Not IsNull(Me.Parent!YearLevel) Then
Me!YearLevel = Me.Parent!YearLevel
End If

If Not IsNull(Me.Parent!SchoolDate) Then
Me!SchoolYear = Year(Me.Parent!SchoolDate)
End If

End Sub

Use Year() instead of DatePart() for the Year - easier.

Suggestions on table design:

1. It is not usually acceptable to have redundant data in 2, or more,
tables - the YearLevel is in both the main table (main form) and its
dependent table (subform).

2. The same for SchoolYear (a name I invented 'cuz you didn't give
the name of the column/field) - if the data is already in the main
(Parent) table the dependent record (subform record) doesn't need it.

You may have reasons for putting those data items in the dependent
table. If they are really good reasons ignore my pendantry.

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP/d/3oechKqOuFEgEQIihACfZqgXeApDKe7bCcyF4NvuPPbCiDUAoL 1F
SJ4wJmFAp+ZTPJ6Q742XcLlW
=0zrJ
-----END PGP SIGNATURE-----
Ray wrote:
I have a subform which takes one of its fields from the main form,
namely the YearLevel which is from 1 to 8. There is also another field
which returns the year from datePart.

If I select a record from the mainform is automatically creates a
record in the subform table even though I have not enter in the school
marks. This obviously comes from the YearLevel and the defaulted year.

is there a way of preventing this occurring. I only want a record in
the subform once I begin to enter the school marks. Maybe this is
impossible. Perhaps a delete query might help if all the score marks
are still null on closure?

Any ideas anyone? TIA - Ray


Nov 12 '05 #2

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

Similar topics

15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
3
by: Mark | last post by:
Is this the way to determine if a subform is dirty? If Me!SFrmEnterActivityList.Form.Dirty Then I use this statement in the Unload event of a form. When I click the Close button, the statement...
2
by: Salad | last post by:
A97. I have a command button to save and exit. I had the code If Me.Dirty Then Docmd.RunCommand acCmdSaveRecord ...more code endif I was getting an error because a value was not getting...
1
by: RC | last post by:
If I want to explicitly save the record before executing a Close action. Which of the following should I use? Or does it depend on whether it is based on a Form or something else? If Me.Dirty...
9
by: Susan Bricker | last post by:
I am currently using the OnDirty event of a Form to detect whether any fields have been modified. I set a boolean variable. Then, if the Close button is clicked before the Save button, I can put...
5
by: Alain Filiatrault | last post by:
Hi, I need to implement a "form.dirty" feature on a VB .NET form not related to a database. I need to know if any of the items (Textboxes, combo, listboxes, ...) was changed. Is there a quick...
1
by: lesperancer | last post by:
I've got a form that is opened in readonly mode and no fields can be changed, great but if I click on a combo box that has an _enter() event that sets a field on my form to a value (albeit the...
5
by: DanielM | last post by:
Please Help - If Me.Dirty I Understood That It Check If any Data in controls had changed. I Have a Form with few textboxes, and On Exit from the form i want to check if data was changed. But It...
1
Ericks
by: Ericks | last post by:
I have a subform that contains several controls of which one is a date control called “DateOfInfoAdded”. The default format of this control is date() so whenever a new record is created the date is...
3
by: dkintheuk | last post by:
So I have a form showing my data items with a selection tick box to indicate when an item is active. I want to save the record automatically when someone clicks in the tick box. So I imagine...
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: 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: 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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.