Avatar of HKFuey
HKFueyFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Access save bound form record

I have this: -

 If Me.Dirty = True Then
  DoCmd.RunCommand acCmdSave
 End If

Open in new window


It gives error 2455 "You entered an expression that has an invalid reference"

I am trying to get a bound form to save after a box is ticked. Can anyone help?
VB ScriptMicrosoft Access

Avatar of undefined
Last Comment
mbizup
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Try with:

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

/gustav
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Try acCmdSaveRecord

If Me.Dirty = True Then
  DoCmd.RunCommand acCmdSaveRecord
 End If

Open in new window

Avatar of HKFuey
HKFuey
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Sorry for not being clear, it errors on line 1

 If Me.Dirty = True Then
SOLUTION
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Where is your code located?

If it is not on the form, you'll need the full reference:

Forms!YourFormName.Dirty
Avatar of HKFuey
HKFuey
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Hi mbizup,

Tried the form name, I still get the error, if I take out the if statement and just leave: -

DoCmd.RunCommand acCmdSaveRecord

It seems to work OK
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Just for kicks, try the same thing on a new (or different) form.
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo