Access'97 and CreateObject scripts

Started by middle.road, November 16, 2016, 01:12:04 PM

Previous topic - Next topic

middle.road

I'm trying to help out some friends who run a vehicle parts business.
They purchased an accounting/inventory program that the sales person said was SQL based and a bunch of other 'features'.
Turns out the bloody program uses Access97.
I'm attempting to come up with some scripts to enhance and make their system more usable.
I'm using version "2003j" Wil "4.2jdb" of WB which is the only version I have.

The PC I setup is running Win7Pro 32bit.   .net 3.5.1 is installed.
Am I attempting to do processes that 2003j can't handle? (or is it operator error?)
I've a gut feeling I don't have something configured properly, else don't understand something basic.
My programming skills are next to nil, and my scripting ability is mediocre.

I used one of the script samples out of the Tech Database to verify the version of the MDB's which I was already certain were Access97.
I was only able to get the desired results changing 'ObjectCreate' to 'ObjectOpen'
I notice too that 'ObjectCreate' syntax doesn't highlight in WB Studio.

_Dan


acSysCmdAccessVer=7
; NADA#  oAcc = CreateObject("Access.Application")
oAcc = ObjectOpen("Access.Application")

Message("Access Version",oAcc.SysCmd(acSysCmdAccessVer) )
Message("oAcc Value is::", oAcc)
oAcc=0
;Exit
;Or here is some other code:

; Version Information Example WinBatch Script
cMDB           = AskFileName("Select ACCESS Database",".\","MDB Files|*.mdb|","*.mdb",1)
cConn          = StrCat("Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=",cMDB)
; or if password protected
;cConn         = StrCat("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=",cMDB,";Jet OLEDB:Database Password=test"")
DB             = ObjectOpen("ADODB.Connection")
DB.Open(cConn)
objProp = DB.Properties
objItem = objProp.Item('Jet OLEDB:Engine Type')
ver = objItem.Value

Switch ver
Case 4
verstr = "97"
break
Case 5
verstr = "2000"
break
Case ver
verstr = "*UNKNOWN""
break
EndSwitch
msg = StrCat("'",cMDB,"' was created using Access version ", verstr)
Message("Version Finder",msg)
ObjectClose(objItem)
ObjectClose(objProp)
ObjectClose(DB)
Exit




Then I tried the "export MDB to Flat File" based on another sample script.

When I go to run it I can't get past:
oApp = ObjectCreate( 'Access.Application' ) ; Open Access Object
error #3052 Uninitialized variable....

Also tried it with ObjectOpen and that at least opened Access, then it Errored out on 'ObjectConstantsGet'


filename = '<PATH><FileName>.mdb'         ;'C:\temp\logfile.mdb'
tablename =  'Table'
outputfile = '<PATH><FileName>.Log'
spec = ''
acSysCmdAccessVer=7
; Export .MBD data to flat file
;NADA oApp = ObjectCreate( 'Access.Application' ) ; Open Access Object
oApp = ObjectOpen("Access.Application") ; Open Access Object
Message("oApp Value is::", oApp)

oConstants = ObjectConstantsGet( oApp ) ; Creates a Constants object.
oApp.OpenCurrentDatabase ( filename ) ; Open Database
oApp.Visible = @TRUE ; Make access visible( change to @false to hide)
oApp.DoCmd.TransferText( oConstants.acExportDelim, spec, tablename, outputfile, @TRUE) ; Export data

;Close objects
oConstants = 0
oApp = 0

Exit

td

The WinBatch COM Automation subsystem was completely re-written in 2004.  You are receiving the errors because the functions you are attempting to use did not exist in 2003.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

middle.road

Ah, missed it by -->||<-- that much. That explains CreateObject not highlighting in studio.
Thanks for pointing that out. I might have chased my tail for several unproductive days.

Now then gotta figure out what to do...