Save not available?

  • Thread starter Thread starter Jim Shaw
  • Start date Start date
J

Jim Shaw

BlankContext: Access 2002

I enter some data into a field in a sub-form which is displaying a record
from an underlying query. Then without exiting the field, I click on a
command button to save the record. The result is an error message that the
save function is not available now. However, when I re-retrieve the record,
the entered data is present in the record (indicating that the data was, in
fact, saved)!

Can anyone explain either this, or the kinds of things that set up this
error?
I don't know where to begin my debugging process.

The form does allow edits.
The save command button is wizard generated without modification...It
generated the DoMenuItem command for a save.
Can it be that the save menu item is only available if me.newrecord = true?

Thanks
Jim
 
Jim Shaw said:
BlankContext: Access 2002

I enter some data into a field in a sub-form which is displaying a
record from an underlying query. Then without exiting the field, I
click on a command button to save the record. The result is an error
message that the save function is not available now. However, when I
re-retrieve the record, the entered data is present in the record
(indicating that the data was, in fact, saved)!

Can anyone explain either this, or the kinds of things that set up
this error?
I don't know where to begin my debugging process.

The form does allow edits.
The save command button is wizard generated without modification...It
generated the DoMenuItem command for a save.
Can it be that the save menu item is only available if me.newrecord =
true?

Thanks
Jim

Where is the Save button you are clicking? If it's on the main form,
not on the subform, then the record will already have been saved
automatically as the focus shifts from the subform to the main form.
And if the focus is now on the main form, the Save menu item will apply
to the main form and will only be available if the main form is bound
and allows updates/additions.
 
The data entry in the Subform is automatically saved when you moved the
Focus from the Subform to the Main Form (i.e. when you click the Save button
in the Main Form). Also, there is nothing to be saved in the Main Form when
you click the Save button.

This is known as the AutoSave feature of the SubformControl. Also, this
feature will automatically save the Record in the Main Form if you move the
Focus from the Main Form to the Subform.

Note that the Form / Subform combination is primarily designed for
displaying / manipulating Records from (in general) 2 Tables in a
One-to-Many relationship where the Main Form is bound to the One (Parent)
Table and the Subform is bound to the Many/Child Table. The main purpose of
the AutoSave feature is to preserve the data integrity in a One-to-Many
relationship (i.e. Child Records cannot be created without a valid Parent
Record).
 
Van;
The save button is on the sub form. If what you say about the AutoSave
feature, the record would have been saved when I entered the field data?
That leads me to say that I can trap the error and ignore it safely?
Jim
 
The save command button in on the sub form.

The only thing I can think of, then, is that there is code that saves
the record in the Exit or AfterUpdate event of the field, which will
naturally fire when you click on the button and thus transfer the focus
there.

You could change the code behind to button to only save if the record is
"dirty":

If Me.Dirty Then
RunCommand acCmdSaveRecord
End If

The "RunCommand" method is preferable to the wizard-generated DoMenuItem
code, anyway.
 
Well, I tried your suggestion (IF Me.Dirty then RunCommand
acCmdSaveRecord.....)
I traced it as it executed. Me.Dirty was equal to "true' so the RumCommand
tried to execute, but I still got the message that the save command was not
available now. However, the data was saved as before.

Any additional thoughts?

Jim
 
Jim Shaw said:
Well, I tried your suggestion (IF Me.Dirty then RunCommand
acCmdSaveRecord.....)
I traced it as it executed. Me.Dirty was equal to "true' so the
RumCommand tried to execute, but I still got the message that the
save command was not available now. However, the data was saved as
before.

Any additional thoughts?

So you're saying that, when you stepped through the code, the error was
raised when it attempted to execute the RunCommand statement? And yet
Me.Dirty was True. How odd.

This code is in the Click event of a command button on the subform? You
aren't trying to execute it in the subform's BeforeUpdate event, or
anything odd like that?
 
Dirk Said:
So you're saying that, when you stepped through the code, the error was
raised when it attempted to execute the RunCommand statement? And yet
Me.Dirty was True. How odd.

Yes, that's what I'm saying. I just stepped through again after adding a
message box to display "Me.AllowEdits" just before executing the RunCommand
statement. It showed Me.AllowEdits = true.
This code is in the Click event of a command button on the subform? You
aren't trying to execute it in the subform's BeforeUpdate event, or
anything odd like that?

Yes, the code is in the Click event of a command button on the subform.
There is an AfterUpdate event for the form that calls a module that
evaluated the effect of the saved data, but the trace sayes it doesn't get
called before the error message.

As near as I can tell, everything I'm doing is very straight forward. I do
have an OnCurrent event handler, but it only controls the visibility of the
data field based on the radio button value of a frame control.

Yes, I too am puzzled by this.
 
Jim Shaw said:
Dirk Said:


Yes, that's what I'm saying. I just stepped through again after
adding a message box to display "Me.AllowEdits" just before executing
the RunCommand statement. It showed Me.AllowEdits = true.

Yes, the code is in the Click event of a command button on the
subform. There is an AfterUpdate event for the form that calls a
module that evaluated the effect of the saved data, but the trace
sayes it doesn't get called before the error message.

As near as I can tell, everything I'm doing is very straight forward.
I do have an OnCurrent event handler, but it only controls the
visibility of the data field based on the radio button value of a
frame control.

Yes, I too am puzzled by this.

There's got to be some factor we're overlooking. If you'd like to send
me a cut-down copy of your database, containing only the elements
necessary to demonstrate the problem, compacted and then zipped to less
than 1MB in size (preferably much smaller) -- I'll have a look at it,
time permitting. You can send it to the address derived by removing NO
SPAM from the reply address of this message.
 
Back
Top