Run-time error 2046 - need help with workaround

D

Don Johnson

I have created a form in an Access 2007 database which on loading runs an
event procedure that modifies one of the fields in the query, and thereby, a
field in the table which is a source for the query. This table is a linked
table in an Access 97 database. The sole purpose of this form is to run the
Visual Basic code to modify this field.

Now, when I attempt to open this form, I frequently get the following message:
Run-time error ‘2046’:
The command or action ‘OpenForm’ isn’t available now.

My Visual Basic code contains the following line which is causing the problem:
DoCmd.GoToRecord acDataForm, “frmAssignPSHNoâ€, acNext

This form and code had been running without issue until I installed Office
2007 Service Pack 2 to solve some instability I was experiencing with some
Excel spreadsheets. Prior to installing Service Pack 2, I had never gotten
this message.

Now, I usually get this message although it will appear at various times.
The record source for this form is a query which usually contains 1 to 200
records. Sometimes, I will get the above message on the first record. Other
times, I will get the message on the ninth record. I have been unable to
discern a pattern as to what the situation is that is triggering the message.

For example, this morning the query contained 11 records. The first time I
ran the form I received the message in trying to move from the first to the
second record using Debug. I then stopped the execution, closed the form and
the database, reopened the database and tried to open the form and thereby
rerun the code. Again I got the message at the same place as it attempted to
move from the first to the second record. I again stopped the execution and
not only closed the database but also closed Access 2007. I then reopened
Access 2007 and opened the same database. This time when I opened the form,
the error did not occur until it was trying to move from the ninth to the
tenth record. There were no changes made to the database.

I thought that I could get around this problem by directly editing the query
records in the Visual Basic code. However, when it gets to the line
rec.Edit
where I have already defined “rec†previously with
Set rec = db.OpenRecordset(“qryMechMfrModUnâ€, dbOpenDynaset)
I get the error message
Run-time error ‘3027’:
Cannot update. Database or object is read-only.

I thought that the dbOpenDynaset would allow me to edit the record. If I
open the query “qryMechMfrModUn†I am able to manually update the desired
field.

Obviously I am missing something but I do not know what I am doing wrong.
Any suggestions?
 
J

Jeanette Cunningham

Hi Don,
first I suggest that you open the form without using the load event to run
the update query.
Put a command button to run the update query.
Then use Me.Requery to move the form to the updated data.

If this works fine, then we can look at what you are trying to do with -->
DoCmd.GoToRecord acDataForm, "frmAssignPSHNo", acNext


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
C

Charles Wang [MSFT]

Hi Don,
Good morning!

Regarding this issue, I agree with Jeanette's suggestion. Could you please
let us know what everything is going on? If this issue persists, could you
please send me (changliw_at_microsoft_dot_com) a test access database so
that I can easily reproduce this issue and perform effective research?

Thank you!

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: (e-mail address removed).
=========================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top