Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 28th, 2018, 08:35 AM
Friend of Wrox
Points: 912, Level: 11
Points: 912, Level: 11 Points: 912, Level: 11 Points: 912, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2005
Location: Dublin, , Ireland.
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
ComputerIsOnline = False
Exit Function
End Function
Brendan Bartley
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 jarasadil@gmail.com 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

All times are GMT -4. The time now is 09:43 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.