error caused by If Dirty Then DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

J

Jason

I tried using Save Record as below but I get the error that AcSaveRecord is
not available. One reason could be that the table is read only. Clicking
Records - Save Record Alt-Enter works but the code doesn't. On the off
chance I thought I would try refresh as a way to close and open the
form/table - that works but why?

'If Dirty Then DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
If Dirty Then Refresh
docmd.openreport .....

thanks,
J
 
J

Jason

I tried using Save Record as below but I get the error that AcSaveRecord is
not available. One reason could be that the table is read only. Clicking
Records - Save Record Alt-Enter works but the code doesn't. On the off
chance I thought I would try refresh as a way to close and open the
form/table - that works but why?
'If Dirty Then DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
If Dirty Then Refresh
docmd.openreport .....

thanks,
J
 
J

John Vinson

I tried using Save Record as below but I get the error that AcSaveRecord is
not available. One reason could be that the table is read only. Clicking
Records - Save Record Alt-Enter works but the code doesn't. On the off
chance I thought I would try refresh as a way to close and open the
form/table - that works but why?

'If Dirty Then DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
If Dirty Then Refresh
docmd.openreport .....

thanks,
J

I'm confused.

If the table is read only, then you cannot write to it.
If you cannot write to it, you obviously cannot save a record to it!

I'd normally use (with an updateable recordset) the simpler code:

If Me.Dirty = True Then Me.Dirty = False

but if you just want to refresh or requery, just

Me.Refresh

or

Me.Requery
 
J

Jason

So turning Dirty off forces a save? The form/table is not read-only. I
haven't even disabled allowadditions nor allowdeletions.
 
J

John Vinson

So turning Dirty off forces a save?

Yes, it does. Not very well documented but it works and it's clean and
compact.
The form/table is not read-only. I
haven't even disabled allowadditions nor allowdeletions.

Your message said:

I tried using Save Record as below but I get the error that
AcSaveRecord is not available. One reason could be that the table is
read only.

which I read as meaning that the table is read only (since that's what
you said).
 
J

Jason

Actually the read only part is part of what Access said in it's error
message - sorry for not explaining this better.
 

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