Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 28th, 2018, 08:35 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 181
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to run Module Form Load

I have a module that checks if the network Drive is available and a message appears true or false if available or not, I am using the following code to do this. I can run this module when I open the code when I press F5, but I want to run the module when the form loads.Module name is Module1.


Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32.dll" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long

Sub CheckAllConnections()
ServerOn = ComputerIsOnline("server.mmc.local")
BDrive = CreateObject("scripting.filesystemobject").driveex ists("B")
test = BDrive - 1
ProgramFolder = False
If ServerOn + BDrive = -2 Then
ProgramFolder = Len(Dir("B:\Helpdeskinc\")) > 0
End If
MsgBox ("The Helpdeskinc Share Drive available is " & BDrive _
& Chr(10)), vbInformation
End Sub

Public Function ComputerIsOnline(ByVal strComputerName As String) As Boolean

On Error Resume Next
Kill "C:\Logger.txt"
On Error GoTo ErrorHandler
ShellX = Shell("cmd.exe /c ping -n 1 " & strComputerName & " > c:\logger.txt", vbHide)
lPid = ShellX
lHnd = OpenProcess(&H100000, 0, lPid)
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, &HFFFF)
CloseHandle (lHnd)
End If
FileNum = FreeFile
Open "c:\logger.txt" For Input As #FileNum
strResult = Input(LOF(1), 1)
Close #FileNum
ComputerIsOnline = (InStr(strResult, "Lost = 0") > 0)
Exit Function
ErrorHandler:
ComputerIsOnline = False
Exit Function
End Function
__________________
Brendan Bartley





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 12 and 13 Unable to find WROX.Suggestion module on website mfresa BOOK: Professional DotNetNuke 5: Open Source Web Application for ASP.NET ISBN: 978-0-470-43870-1 0 September 3rd, 2010 03:31 PM
General Exception and Module Load Err jivemedia BOOK: Professional DotNetNuke Module Programming ISBN: 978-0-470-17116-5 11 March 18th, 2010 11:14 AM
load balancing of server directly with servlets/jsp, without using mod_jk module [email protected] Apache Tomcat 0 January 6th, 2010 08:30 AM
Unable to load DLL 'webengine.dll': The specified module could not be found??? Ron Howerton ASP.NET 2.0 Professional 2 September 2nd, 2009 01:09 PM
unable to load 20525 dinellest Crystal Reports 0 February 17th, 2009 04:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.