How to replace Docmd.Domenuitem with RunCommand in MS Access 2010
-
mercredi 9 mai 2012 15:58
I have Access 2003 database and there is a button "Import Data" on a form. Following is the code for button "Import Data" which works fine in access 2003 but throws error "Run time error 3021, No current record" in access 2010.
Private Sub btnImportData_Click()
DoCmd.DoMenuItem acFormBar, 0, 2, 0, acMenuVer70
End Sub
I searched on net and i came to knew that Docmd.Domenuitem wan't work in access 2010 and it needs to be replaced with RunCommand.
Any suggestion for change in code.
Thanks
- Modifié zaveri cc mercredi 9 mai 2012 15:58
Toutes les réponses
-
mercredi 9 mai 2012 16:19
There's a whole slew of commands in Access 2010, depending on whether you want to import data from another Access database, from Excel etc. For example, to import from another Access database:
RunCommand acCmdImportAttachAccess
Regards, Hans Vogelaar
- Marqué comme réponse zaveri cc vendredi 11 mai 2012 14:46
-
mercredi 9 mai 2012 16:22
Hi Hans,
Thanks for quick response.
I think it import data from same access table and following code works well in access 2003. Based on following code can you suggest any change i should make to the code?
Private Sub btnImportData_Click()
DoCmd.DoMenuItem acFormBar, 0, 2, 0, acMenuVer70
End Sub
-
mercredi 9 mai 2012 16:36Have you tried the line that I posted?
Regards, Hans Vogelaar
-
vendredi 11 mai 2012 14:46
Yes i tried your suggestion and it worked. Thanks.

