[AccessD] VBA Runtime Error

Jim Lawrence accessd at shaw.ca
Thu Aug 17 06:07:38 CDT 2006


... Of course, Access cannot do things such as install your app as a Windows
service..

...but with an A2K managed VBS script it can; example:

<code>
' This code creates and starts the MyMonitor Perl service
' ---------------------------------------------------------------
' From the book "Windows Server Cookbook" by Robbie Allen
' Publisher: O'Reilly Media
' ISBN: 0-596-00633-0
' Book web site: http://rallenhome.com/books/winsckbk/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strComputer   = "."
strSvcName    = "MyMonitor"
strSrvAnyPath = "c:\Windows Resource Kits\Tools\srvany.exe"
strPerlPath   = "c:\perl\bin\perl.exe"
strPerlScript = "c:\scripts\monitor.pl"
' ------ END CONFIGURATION ---------

const HKLM = &H80000002

' Service Type
Const KERNEL_DRIVER       = 1
Const FS_DRIVER           = 2
Const ADAPTER             = 4
Const RECOGNIZER_DRIVER   = 8
Const OWN_PROCESS         = 16
Const SHARE_PROCESS       = 32
Const INTERACTIVE_PROCESS = 256

INTERACT_WITH_DESKTOP = FALSE

' Error Control 
Const NOT_NOTIFIED     = 0
Const USER_NOTIFIED    = 1
Const SYSTEM_RESTARTED = 2
Const SYSTEM_STARTS    = 3

set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set objService = objWMI.Get("Win32_Service")
intRC = objService.Create(strSvcName, _                 
                          strSvcName, _
                          strSrvAnyPath, _ 
                          OWN_PROCESS, _ 
                          NOT_NOTIFED, _
                          "Automatic", _ 
                          INTERACT_WITH_DESKTOP, _
                          "NT AUTHORITY\LocalService",_
                          "")
if intRC > 0 then
   WScript.Echo "Error creating service: " & intRC
   WScript.Quit
else
   WScript.Echo "Successfully created service"
end if

strKeyPath = "SYSTEM\CurrentControlSet\Services\" & _
             strSvcName & "\Parameters"
set objReg = GetObject("winmgmts:\\" & _
                       strComputer & "\root\default:StdRegProv")
objReg.CreateKey HKLM,strKeyPath
objReg.SetStringValue HKLM,strKeyPath,"Application",strPerlPath
objReg.SetStringValue HKLM,strKeyPath,"AppParameters",strPerlScript
WScript.Echo "Created registry values"

set objService = objWMI.Get("Win32_Service.Name='" & strSvcName & "'")
intRC = objService.StartService
if intRC > 0 then
   WScript.Echo "Error starting service: " & intRC
else
   WScript.Echo "Successfully started service"
end if
</code>

Just a comment.
Jim


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of artful at rogers.com
Sent: Thursday, August 17, 2006 1:56 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] VBA Runtime Error

I don't know a soul on the MS development team, but my conclusion from the
outside is that Access is regarded as a toy by those within (not its
developers, those around and above them). The toy got uppity and developed a
following (us), and Microsoft seniors didn't and still don't know what to do
about it. So they go along, within limits, but to the extent that Access
succeeds as a professional development platform, it undermines the much
pricier products llike VS.NET. Of course, Access cannot do things such as
install your app as a Windows service, and lots of other things too -- but
this reinforces my point. I'm sure the Access dev team could supply this
functionality, but they are not allowed to. 

A.

----- Original Message ----
From: William Hindman <wdhindman at dejpolsystems.com>
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Sent: Wednesday, August 16, 2006 5:26:09 PM
Subject: Re: [AccessD] VBA Runtime Error

...I've never understood why something so fundamental isn't the default for 
every new module ...its not like MS is doing anyone any favors or closing 
any options :(

...but what the heck ...we got a transparent gui, ribbons, and sharepoint in

A2K7 ...who needs real fixes, much less common sense.

...I was reading the blog of one of the Access team members and he started 
going on about how he knew what real developers needed because after all 
they had to write the sample mdbs themselves.

...sorta choked me up ...lost a diet coke all over the screen, I did.

...and then there was the team lead all indignant about repeated requests 
for autocorrect to be off by default ...wanted everyone to know just how 
much work he'd put into that feature and that it worked right fine in his 
opinion :(

William

----- Original Message ----- 
From: "JWColby" <jwcolby at colbyconsulting.com>
To: "'Access Developers discussion and problem solving'" 
<accessd at databaseadvisors.com>
Sent: Wednesday, August 16, 2006 3:59 PM
Subject: Re: [AccessD] VBA Runtime Error


> Boy howdy, I second THAT one.  Option explicit is a requirement in my 
> book.
>
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of MartyConnelly
> Sent: Wednesday, August 16, 2006 2:54 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] VBA Runtime Error
>
> You might want to put statement Option Explicit in all your modules to 
> force
> variable declaration and recompile
>
> Kaup, Chester wrote:
>
>>This is a single database thus front end back end. It stops in the same
>>place every time. I think I may have solved the problem. I did not dim
>>a date variable - just let access do it. I dimmed it and code is now
>>running.
>>
>>
>>-----Original Message-----
>>From: accessd-bounces at databaseadvisors.com
>>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of JWColby
>>Sent: Wednesday, August 16, 2006 10:40 AM
>>To: 'Access Developers discussion and problem solving'
>>Subject: Re: [AccessD] VBA Runtime Error
>>
>>Is it consistent?  Perhaps a corrupt FE or BE.  Is it intermittent or
>>one time?  Perhaps a bad NIC or other network problem.
>>
>>
>>John W. Colby
>>Colby Consulting
>>www.ColbyConsulting.com
>>
>>-----Original Message-----
>>From: accessd-bounces at databaseadvisors.com
>>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kaup,
>>Chester
>>Sent: Wednesday, August 16, 2006 11:18 AM
>>To: Access Developers discussion and problem solving
>>Subject: [AccessD] VBA Runtime Error
>>
>>Had the following error come up when running VBA code in a module. Line
>>it stopped on set a variable to a table field in a native table. What
>>does it mean?
>>
>>
>>
>>Run-time error '-2147417848(80010108)'
>>
>>
>>
>>Automation error
>>
>>The object invoked has disconnected from its clients.
>>
>>
>>
>>Chester Kaup
>>
>>Engineering Technician
>>
>>Kinder Morgan CO2 Company, LLP
>>
>>Office (432) 688-3797
>>
>>FAX (432) 688-3799
>>
>>
>>
>>
>>
>>No trees were killed in the sending of this message. However a large
>>number of electrons were terribly inconvenienced.
>>
>>
>>
>>--
>>AccessD mailing list
>>AccessD at databaseadvisors.com
>>http://databaseadvisors.com/mailman/listinfo/accessd
>>Website: http://www.databaseadvisors.com
>>
>>
>>
>
> --
> Marty Connelly
> Victoria, B.C.
> Canada
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list