[RESOLVED] error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
i am using a function in a module to open a form and add lines of code to the form's module. when i try to save the form using "DoCmd.RunCommand acCmdSaveRecord" i get the error "The command or action 'SaveRecord' isn't available now". what is stopping me from saving?
Re: error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
You are opening the form in design mode?
Re: error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
yes.
should it be opened in a different way? i was sure it needed to be design mode to edit the code in the form's module.
Re: error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
Can you post some relevant code?
Re: error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
VB Code:
Dim frm As Form, db As Database, con As Container, doc As Document
Dim mdl As Module
Set db = DBEngine(0)(0)
Set con = db.Containers("Forms")
For Each doc In con.Documents
DoCmd.OpenForm doc.Name, acDesign
Set frm = Forms(doc.Name)
Set mdl = frm.Module
'add code to form's module here
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, doc.Name
Next
Re: error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
Even though your opening the Form in design view, you actually tieing up the connection when you modify the module code that
is bound to the form. You need to try to modify it from the Application.VBE object. Checkout my CodeBank code on
"VB6 - Modify VBA Macro Code From VB". It shouldnt be too much to modify it for internal VBA use. ;)
Re: error: The command or action 'SaveRecord' isn't available now (MS-Access 2003)
great!
thanks for the help.