Add Value to Subform If Not Null

I have a main form that contains 3 subforms.  The subforms capture Material Usage data for the associated machine and the data is stored in tbl_MaterialUsage.

tbl_MaterialUsage
=============
MaterialUsageID (PK)
ProdID (FK - Parent Field to subforms)
Material ID
MaterialUsage (Amount)
Machine ID

The attached screenshot shows the subforms...Each line is a subform that corresponds to a specific machine.  I need a way of storing that machine ID, but I do not want to store records unless the user enters information in the Material and Usage fields on that subform.  ProdID, MaterialUsageID, and MachineID are hidden in the subform.

Also, if you have any other methods or design suggestions, I would love to hear them as I suspect my use of multiple subforms may not be the most effective.
FormSample.bmp
alliedtechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wiswalldCommented:
I am a little confused. You want to add a machine ID to the subform but if they do not fill in the other fields to not save the record?
0
alliedtechAuthor Commented:
My overall goal is to avoid saving records that do not have a Material or a Usage.  If I set the Machine ID to a default value, then I believe the record would always be saved.  Not every machine is used on every job.  I hope this helps.
0
wiswalldCommented:
I am thinking something like this but still trying to figure where to put it.



If MsgBox("Do you want to save? (click 'No' to undo)", vbYesNo, "Save") = vbYes Then
'Save
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
Else
'Undo
Me.Undo
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

wiswalldCommented:
Or on your navigation button for new put

If Me.Field2 = False Then
Me.Undo
End If
0
alliedtechAuthor Commented:
The main form has numerous data entry fields such as Date, Job #, etc...

My original thought was set a default MachineID for in each subform and then to incorporate code behind the "save" command button that would check the values of the subforms, and if they were null, then set the MachineID as null.  Does this sound like the right path?
0
wiswalldCommented:
That is what I was getting at. Basically I took a field on the form other than the machine ID that would normally be filled out, check for a value, and if null undo any changes (not save)
0
alliedtechAuthor Commented:
Yea - I will work on that and post if I have any troubles.  Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.