[Solved] Macro to save record

Discuss the database features
Post Reply
seba13_13
Posts: 2
Joined: Wed Jul 03, 2019 10:37 am

[Solved] Macro to save record

Post by seba13_13 »

Hello

I am a beginner in macro. I try to do macro which save the record after text modified.
I tried:

Code: Select all

sub zapiszformularz
	DoCmd.RunCommand acCmdSaveRecord
end sub
and it work for two days! But now its error : Basic runtime error. Object variable not set. I didn't change anything in form or in macro. I don't know what happend :(
I also tried Me.Dirty but it show the same error.

Could anyone tell my what I'm doing wrong or has other solution to this macro?
Last edited by seba13_13 on Fri Jul 05, 2019 10:42 am, edited 1 time in total.
OpenOffice 4.1.6 / Win 10
Bidouille
Volunteer
Posts: 577
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: Macro to save record

Post by Bidouille »

For me, DoCmd is not Basic but VBA.
Except if you use Access2Base : viewtopic.php?f=47&t=61447
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro to save record

Post by Villeroy »

Add a push button to the form.
Action = Save (or Next Record which saves before moving)
Default button = Yes

Now the record will be saved when you hit the enter key.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
seba13_13
Posts: 2
Joined: Wed Jul 03, 2019 10:37 am

Re: Macro to save record

Post by seba13_13 »

I still don't know why this macro, once work, another time don't, maybe it is a matter of difference in vba and vb.
But I found another solution on polish forum - macro which save record and refresh form.

https://forum.openoffice.org/pl/forum/v ... =13&t=4721

Code: Select all

sub Zapisz
dim document   as object
dim dispatcher as object
' -------------------------------------------------
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:RecSave", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:Refresh", "", 0, Array())
End Sub
OpenOffice 4.1.6 / Win 10
Post Reply