One of those days when simple is not - Saving is not saving

Zydeceltico

Registered User.
Local time
Today, 11:47
Joined
Dec 5, 2017
Messages
843
HI all - super simple mockup attached.

Two tables, two forms. Tables are related via the CampingTrip_ID field. The value of CampingTrip_ID is passed from one form to the other via OpenArgs and converted to a Long before being entered in the field control on the second form.

The user opens frmCampingTrip and makes some selection; clicks a button to open frmTripDetails to enter some more info and clicks a save button on the second form which should save data from both forms to the underlying bound tables; close the second form; return to the first form; and requery the first form.

This all works - except that data is only recording in tblCampingTrip and not in tblTripDetails even though frmTripDetails appears to be receiving OpenArgs correctly.

I'm clearly missing something simple but for the life of me can't figure it out.

Thanks,

Tim
 

Attachments

Although you are assigned a CampingTrip_ID, a record is not created in tblCampingTrip. Because you have referential integrety between your tables nothing is saved in tblTripDetails because there is not yet a record in tblCampingTrip.

Force a save on the frmCampingTrip button, then open the frmTripDetails.

DoCmd.RunCommand acCmdSaveRecord
 
You might consider a form/subform. Is this an analogy/mock up for some other application??
 

Attachments

  • campingTripWithDetails.png
    campingTripWithDetails.png
    148 KB · Views: 127
you have the main form's property Data Entry set to Yes, that is why
you only see New record.
 

Attachments

Is this an analogy/mock up for some other application??

Hi JDraw - yes - it s a mockup. In fact, it is a mockup for a different question.

It is meant to be an anology for the structure I already have in place and that has been working as expected for a year.

Thinking about how the real db works and specifically when a record is recorded to the first table, I think plog is correct. I need to force a save on the first form's data when opening the second form although I don't immediately recognize where that happens in the real db.

I do notice that - in the real db - on the form that represents frmCampingTrip in the mockup - the code attached to the button that would open frmTripDetails has this as its first line: Me.Dirty = False before the DoCmd.OpenForm statement.

Is that line what is allowing me to move to the second form and record data to its underlying table while the first form is still open?
 
I do notice that - in the real db - on the form that represents frmCampingTrip in the mockup - the code attached to the button that would open frmTripDetails has this as its first line: Me.Dirty = False before the DoCmd.OpenForm statement.

Is that line what is allowing me to move to the second form and record data to its underlying table while the first form is still open?

Yep - adding Me.Dirty = False results in exactly what I expected to see. Now I can move on to my real question. :-)
 
Good stuff. If you have 2 tables that are in a 1 to many relationship, then Form /subform is a typical way to handle this. If you have to move from Form1 to Form2 with a close, then open, then that could be a different scenario.
Still interested in your project---and we all seem to have a little time on our hands these days.
 
Good stuff. If you have 2 tables that are in a 1 to many relationship, then Form /subform is a typical way to handle this. If you have to move from Form1 to Form2 with a close, then open, then that could be a different scenario.
Still interested in your project---and we all seem to have a little time on our hands these days.
Thanks jdraw. A long time ago I thought about approaching this whole project with subforms but there were certain peculiarities in our real world workflow that precluded that idea. I just posted my new question about an hour ago and I am certain that form/subform would have made this particular challenge a no-brainer but I'm way too far along with the big picture to backtrack that far at this juncture.

Good news is that when I can figure out a solution to my current question (in my new post) I believe I will be finished with the overall design/structural phase and can start badgering you about error handling and debugging! :)
 

Users who are viewing this thread

Back
Top Bottom