Error message 2950 when attempting to save a record

  • Thread starter Thread starter Mel
  • Start date Start date
M

Mel

I created a form populated by a query ("update form query") The reason for
the form is to update records when needed. I added a button ("SAVE RECORD")
with an embeded macro whose action is "save" with an argument of "query,
update form query". When I change a value on the form and click "SAVE
RECORD" I get an error message (error number 2950) saying that the "update
form query" is not open. When I check, however, the query and table are both
updated.

Any suggestions?
 
Mel said:
I created a form populated by a query ("update form query") The reason for
the form is to update records when needed. I added a button ("SAVE
RECORD")
with an embeded macro whose action is "save" with an argument of "query,
update form query". When I change a value on the form and click "SAVE
RECORD" I get an error message (error number 2950) saying that the "update
form query" is not open. When I check, however, the query and table are
both
updated.

One problem is that I don't understand what you mean. "Populated by a
Query" could mean that the Query is the RecordSource for the Form; or it
could mean that you have an unbound form, that you run Query, and that you
move the data to the Form. In the latter case, you'd have to pick up the
data from the (unbound) Controls on the Form and execute an Update Query to
update the table.

Queries are not "updated" -- they retrieve data from tables (either directly
or via other tables), update data, delete data, or append data, but they are
not themselves "updated".

The normal, and simple, way to update data is with a bound Form... that is,
a Form with a Record Source of either a Table or a Query, and with Controls
having a Control Source of Fields in the RecordSource. Changes to the
Controls on the Form are automatically saved when you close the Form, when
you move to a different Record, or when you move back and forth to/from
Subform Controls. The "Save" operation is just there to ensure an update in
case none of those have occurred -- and it is available in macros and in the
DoCmd statement in VBA code.

However, not understanding what you have and what, exactly, you have done, I
can't offer suggestions about your specific case.

I do all my work with VBA code, so I am not the one to discuss macros. For
years, I have thought that VBA was at least as simple and straightforward as
macros, but the product team or those who give them direction seem to think
there's really a reason. Their most recent "reason" for pushing macros is
"security".

Larry Linson
Microsoft Office Access MVP
 
I am aware of the changes to the controls being automatically saved on
closing of the form. I would rather not have to close and re-open the form
whenever I have eight or ten records to update. The query is the
RecordSource for the form. The query has data from 5 related tables. What I
would like to do is be able to click a button, causing all the changes to the
displayed record saved to the tables, with the record displayed on the form
with the updated data.

I am new to Access 2007, but I used two versions back before I retired. I
also used some much more powerful applications (e.g. SAS). Access 2007 is
very difficult to teach yourself.
 
I am aware of the changes to the controls being automatically saved on
closing of the form. I would rather not have to close and re-open the form
whenever I have eight or ten records to update. The query is the
RecordSource for the form. The query has data from 5 related tables. What I
would like to do is be able to click a button, causing all the changes to the
displayed record saved to the tables, with the record displayed on the form
with the updated data.

If the query is indeed updateable (many five-table queries aren't!) you can
use the SaveRecord Macro action, or DoCmd.RunCommand acCmdSaveRecord in VBA;
another way to do so in VBA is

If Me.Dirty Then Me.Dirty = False

This will save the record and should redisplay the data on the form; if it
doesn't, Me.Repaint should do so.
 
Back
Top