Save a Record before user input

cinders

Registered User.
Local time
Today, 22:30
Joined
Aug 28, 2001
Messages
48
Hello,

My odd situation is that I have a form, this form has some fields which default from a different form. I need the record to save with the default values before the user types anything into the form. I would like to save the information already contained in the form when the user tabs to the next field.

Is there a way to do this?

And...I know there may be questions as to why I want to do this, but there is a logical reason, but it would take far too long to explain. I will go into more detail later if need be, but simply....
Can I have a form, save what appears to be a blank record with some default values upon tabbing to the next field in the tab order, if Yes, how?
 
Don't ask, don't tell. You can put this where you like but I would go for the forms OnCurrent or OnDirty events. Use this:
DoCmd.RunCommand acCmdSaveRecord
HTH.
 
Hi There,

Thanks SO much for your response, this little issue is killing me.

No Luck! I put the coding you suggested on the On Current Event of the form. The record did not save, I still have autonumber showing in my record ID field.

Do you have any thoughts on why it won't execute. I've had a lot of troubles with any form event coding actually working. Is there something I am missing or some setting that I have not updated that allows event programming at the form level to work??? My programming on my form objects works, just no anything on that I input on the overall form?!?!

Thanks

Cindy
 
I think this may be a case of Access outsmarting you. A record doesn't really exist until you enter some data so there is nothing to save. Default values don't dirty a record. Someone actually needs to type something or you need code that will dirty the record.

I strongly recommend against this though because you are likely to end up with stray empty records.

I think you're going to have to tell us your objective. You will find that you get better help from the members when you state a problem rather than asking how to implement what you have determined is the solution.
 
Hi There,

Pat, my objective is to simulate a system that is used on the longshore for managing containers. The containers are tracked as they enter the site. I am working on a simulation for training purposes and am attempting to (loosely) recreate or mock up an existing system.

I'll try and summarize.....

I have form A (the main form) which based on the transaction number entered on the main form will open the associated subsequent form ( form b or c or d etc....) So if you enter transaction type 1, the Deliver Import Form will open, if you enter transaction type - 2, the Deliver Export Form will open etc... The subsequent form will have the first few fields auto populate based on the input of form A, now a field called container number on the subsequent form can either automatically populate from Form A (if the user inputs a value in container number on form A) or they can manually type it in if it is not entered on Form A. The container details (Height, ISO Code, Size etc...) automatically populate based on the container number on the subsequent form (which is either input manually or auto populates from the previous form) I have built the subsequent form to have a subform with the container details fields on it. I have linked the subsequent form (Form B for this example) and the subform on container number, so the container details for that specific container number displays. If the user enters the container number on the subsequent form (form B) this works fine - the link can be made because the value in the container field now exists in a record as it has been manually input, BUT if the container number defaults from the main form, it does not exist in a record and link is unsuccessful , that is why I want to save the record before any manual input is done. The whole point of recreating this, is so the container handlers can practice receiving and exporting containers on a computer terminal as part of their training. Orphaned records are not a concern. We just want a tool for them to be able to practice and to capture some of their input to check for accuracy. Now that is a mouth full, hopefully this sheds enough light on my little project that someone may be able to give me direction. I feel like I've exhausted my options and creativity in getting the system to do what I want (I tried playing with default values, DLookup etc....) This is the closest I've come, and if I could just save the record before the user inputs anything my little application would work exactly as I need it to when the container number defaults on the subsequent form. To further complicate things on the main form the user inputs an appointment ID, the appointment is set to have a start and end time. If the user inputs the appointment ID and the time of input does not fall between the start and end time, a different forms pops up with instructions that takes the user to a whole other area of forms (I have all of this working though so it is not a problem. My concern is the path I take to fix my other problems cannot impact this other convoluted piece involving appointment times.

Note: These default fields populate in the real system before the user types anything into the form so I need to it function like the existing system. If I do a workaround, like getting them to hit the spacebar or something along those lines to save the record they will think they need to take extra steps that are unnecessary in production which will confuse things. We want them practicing as if they were doing it live.

Thanks

Cindy
 
Some place you have code that opens either form A or form B. You will need to add 2 lines of code in front of the OpenForm method. One to dirty the current record and the second to save it.

Me.SomeField = somevalue
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm ......
 
Pat Hartman said:
Me.SomeField = somevalue
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm ......

Hi Pat,

It appears to me this will save the form that is already open (I could be wrong here) I need Form A or Form B to save.

Form A or B opens based on this code:

Dim stFormVar As String
stFormVar = "frmTran" & (Me.TranType)
{Me.TranType can be any one of 1 -5}
So possible forms that open are frmTran1 or frmTran2 or frmTran3 etc... based on what the user inputs for TranType on the 1st form
DoCmd.OpenForm stFormVar

When the stFormVar opens it populates certain form fields with info that was originally on the 1st form. Once that happens I need the newly opened form to save and create a record.

The field on the newly opened form is ContNbr
The field that is on the 1st form that holds that value (which cascades to the newly opened form) is OptContNbr.

So would I have the code set to:

Me.ContNbr=[Forms]![1stForm]![OptContNbr] {to dirty the current record}
DoCmd.RunCommand acCmdSaveRecord {save the current record}

My question is where do I put this code on in the newly opened form? What event will cause it to run? OR do I put it on the original form and the Open form causes it to run and save the new form info??? (I am really confused)

Thanks so much for your help!!!

Cindy :confused:
 

Users who are viewing this thread

Back
Top Bottom