VBA equivalent to RECORDS -> SAVE RECORD

P

paxdak

What's the VBA equivalent to selecting RECORDS -> SAVE RECORD (shift-enter) when on a form?
 
K

Kevin K. Sullivan

Me.Dirty = False

Keep in mind, this will cause an error if the form is not dirty to begin
with, so

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

is typical.

There are other ways to do DoCmd.RunCommand .... but the constants change
between Access versions and I find the code to be cryptic, so I always stick
with the Form's Dirty property.

You could also replace "Me" with a valid reference to a different open form:

Forms(0).Dirty = False
Forms("frmDataEntry").Dirty = False
Forms!frmDataEntry.Dirty = False

HTH,

Kevin
 
D

Dirk Goldgar

Kevin K. Sullivan said:
Me.Dirty = False

Keep in mind, this will cause an error if the form is not dirty to
begin with, so

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

is typical.

Actually, Me.Dirty = False will not cause an error if the form isn't
dirty. It's just that it's marginally more efficient to only do that
when the form is actually dirty.
 
K

Kevin K. Sullivan

Thanks for the update!
Kevin
Dirk Goldgar said:
Actually, Me.Dirty = False will not cause an error if the form isn't
dirty. It's just that it's marginally more efficient to only do that
when the form is actually dirty.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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