WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Access

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

OLE and Named Arguments

Keywords: 	 Named Arguments

Question:

In your docs about OLE, you talk about "named arguments." Are these like the system variables in VBA? For instance if you open a form in MS Access, you can open it for editing using the option ACEDIT. I've tried replacing it with a numeric option, (I understand access uses zero-based subscripts) but this doesn't work either. I also made sure I had the correct number of args such as msaccess.docmd.runmacro "Macro1",,,,,). I also tried "" (for NULL string inside the commas. (to no avail.)

I've got my Winbatch to start Access and open the correct database, but I can't get it to open a form or run a macro. I'm currently using DDE to send the macro commands. I'd prefer to use winbatch for OLE since VB is a little cumbersome.

Here's a sample VB program that works...

Private Sub Form_Load()

Dim AccessDB As Object
Set AccessDB = CreateObject("Access.Application")
' Make Excel visible through the Application object
AccessDB.Application.Visible = True
AccessDB.Application.UserControl = True

AccessDB.Application.OpenCurrentDatabase ("c:\data\access\OMC Region EA.mdb")
AccessDB.DoCmd.OpenForm "Daily"
AccessDB.DoCmd.Close acForm, "Daily"
AccessDB.DoCmd.RunMacro "CSD Daily"

' Close Access with the Quit method on the Application object
AccessDB.Application.Quit

' Release the object variable
Set AccessDB = Nothing

Unload Form1
End Sub
Here's my Winbatch script...
MyDB = ObjectOpen("Access.Application")
dbname = "c:\data\access\duty.mdb"
;MyDB.visible = 1
MyDB.visible = @true
MyDB.usercontrol = 1

MyDB.OpenCurrentDatabase(dbname)

MyDB.DoCmd.openform "Test"
myform = MyDB.Forms(0)
MyDB.DoCmd.openform myform
myform = "Test"
MyDB.DoCmd.openform myform,,,,,

;message("",myform)

message("MS Access","Close Access")

;timedelay(3)
;ObjectClose(MyDB)
I've also tried numerous variations on the openform method (as described previously) As always, thanks for your help...

Answer:

  1. There seem to be no parenthesis on your lines. WinBatch needs parenthesis around all arguments.

  2. Might also need to subdivide the OLE constructs. Try...
    	MyCmd=MyDB.DoCmd
    	MyCmd.openform("Test")
    

    Article ID:   W13664
    
    Filename:   OLE and Access.txt
    File Created: 1999:04:15:16:55:32
    Last Updated: 1999:04:15:16:55:32