Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't understand err. "Object Variable or With Block Variable Not Set"

Status
Not open for further replies.

jimtmelb1

Technical User
Sep 7, 2003
72
AU
Hi,

I have a number of clients that run a little program which copies certain files from a CD to a desired location of their machines. 90% of clients run the program successfuly. I have a few machines that come up with an error. The error is "Runtime Error 91, Object Variable or With Block Variable Not Set"

The function which i presume is causing the problem is shown below. If somebody can tell me why i get this message on some machines i would much appreciate it. I can't understand this problem.

Function GetNetworkConnection() As String

Dim ls_LocalName As String
Dim ls_RemoteName As String
Dim i_iX As Integer
Dim ui_cb As Long
Dim strNetworkString As String
Dim i As Integer
Dim db As Database
Dim rstLookup As Recordset
Dim strLocation As String
Dim intCounter As Integer
Dim strCompanyName() As String
Dim blankLocation As String
Dim workstationSetupLocation As String
Dim ServerSetupLocation As String
Dim strCompany As String
Dim strSupport As String
Dim strHelp As String
Dim dataLocation As String
Dim FSO As Scripting.FileSystemObject
Dim File As Scripting.File

Screen.MousePointer = vbHourglass

Set FSO = New FileSystemObject

i = 0
For i_iX = 1 To 26
ls_LocalName = Chr(64 + i_iX) + ":"
ls_RemoteName = Space(128)
ui_cb = 127

If WNetGetConnection(ls_LocalName, ls_RemoteName, ui_cb) = 0 Then
lstNetworkDrive.AddItem (ls_LocalName + " - " + ls_RemoteName)
strNetworkString = ls_LocalName & "\" & SETUP_FILE_NAME
If FileExists(strNetworkString) Then
i = i + 1
strLocation = strNetworkString
End If
If i = 2 Then
Unload Me
MsgBox "Problem: I have found SETUP.MDE on more than one network drive. Please call the Support Desk on 03 9678 9278. ", vbInformation, App.Title & " - Upgrade Installation"
End
End If
End If
Next

If i = 0 Then

strLocation = Upgrade_Install
Screen.MousePointer = vbDefault
Exit Function

ElseIf i = 1 Then

Set db = DBEngine(0).OpenDatabase(strLocation, , True)
Set rstLookup = db.OpenRecordset("SELECT Value FROM tblLookup WHERE Parameter='CompanyName'", dbOpenSnapshot)
Do Until rstLookup.EOF
lstCompany.AddItem (rstLookup!Value)
strCompany = Left$(strLocation, 3) & rstLookup!Value & "\templates"
strSupport = Left$(strLocation, 3) & rstLookup!Value & "\" & DOCS & "\" & SUPPORT
strHelp = Left$(strLocation, 3) & rstLookup!Value & "\" & DOCS & "\" & HELP

If FileExists(Left$(strLocation, 3) & rstLookup!Value & "\tcsdata.mdb") Then

If Not FSO.FolderExists(strSupport) Then
MkDir Left$(strLocation, 3) & rstLookup!Value & "\" & DOCS
MkDir Left$(strLocation, 3) & rstLookup!Value & "\" & DOCS & "\" & SUPPORT
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "SWLT.PDF", strSupport & "\SWLT.PDF", True
Set File = FSO.GetFile(strSupport & "\SWLT.PDF")
File.Attributes = Archive
Else
If Not FileExists(strSupport & "\SWLT.PDF") Then
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "SWLT.PDF", strSupport & "\SWLT.PDF", True
Set File = FSO.GetFile(strSupport & "\SWLT.PDF")
File.Attributes = Archive
End If
End If

End If

If FileExists(Left$(strLocation, 3) & rstLookup!Value & "\tcsdata.mdb") Then
'If Len(Dir$(strSupport)) = 0 Then
If Not FSO.FolderExists(strHelp) Then
MkDir Left$(strLocation, 3) & rstLookup!Value & "\" & DOCS & "\" & HELP
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "ExportFields.pdf", strHelp & "\ExportFields.pdf", True
Set File = FSO.GetFile(strHelp & "\ExportFields.pdf")
File.Attributes = Archive
Else
If Not FileExists(strHelp & "\ExportFields.pdf") Then
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "ExportFields.pdf", strSupport & "\ExportFields.pdf", True
Set File = FSO.GetFile(strHelp & "\ExportFields.pdf")
File.Attributes = Archive
End If
End If

End If

If Not Len(Dir$(strCompany & "\*.doc")) = 0 Then
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "sdgoods.doc", strCompany & "\sdgoods.doc", True
'FileCopy App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & "sdgoods.doc", strCompany & "\sdgoods.doc"
Set File = FSO.GetFile(strCompany & "\sdgoods.doc")
File.Attributes = Archive
End If
rstLookup.MoveNext
Loop

blankLocation = Left$(strLocation, 3) & CLIENTSIDE_FILE_NAME_BLANK
workstationSetupLocation = Left$(strLocation, 3) & WORKSTATION_SETUP
ServerSetupLocation = Left$(strLocation, 3) & SERVER_SETUP
dataLocation = Left$(strLocation, 3) & DATASOURCE_FILE_NAME_BLANK

Me.txtStages.Visible = True
Me.txtStages.Caption = "Upgrade Installation: Copying new files"
Me.Refresh

FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & CLIENTSIDE_FILE_NAME_BLANK, blankLocation, True
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & WORKSTATION_SETUP, workstationSetupLocation, True
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & SERVER_SETUP, ServerSetupLocation, True
FSO.CopyFile App.Path & IIf(Right$(App.Path, 1) = "\", "", "\") & DATASOURCE_FILE_NAME_BLANK, dataLocation, True
Set File = FSO.GetFile(blankLocation)
File.Attributes = Archive
Set File = FSO.GetFile(workstationSetupLocation)
File.Attributes = Archive
Set File = FSO.GetFile(ServerSetupLocation)
File.Attributes = Archive
Set File = FSO.GetFile(dataLocation)
File.Attributes = Archive



Set rstLookup = Nothing
db.Close
Set File = Nothing
Set FSO = Nothing

Screen.MousePointer = vbDefault
Beep
Me.txtStages.Visible = False
Me.Refresh
MsgBox "Success! The Upgrade files have been copied successfully!", vbInformation, App.Title & " - Upgrade Install"
End


End If

Screen.MousePointer = vbDefault
GetNetworkConnection = strLocation

End Function
 
I don't have that info. I haven't been able to go the clients machines and run from their computer. I have not got the problem myself.

Can anybody see the code and pick where the error may come from.

Regards
jim
 
I'm not sure, but maybe the machines where the error is does not have the same MDAC installed.
 
Something that may help you find these sorts of errors is to add line numbers, and in your error logging routine (which I guess you left out for posting) use the undocumented Erl function. This gives you the line number where the error ocurred.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top