[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Object Variable or With Block Dilema!!!

When I run my Visual Basic Project after running with a full compile everything works fine. But, when I make a EXE and run it it comes back and tells me that the Object Variable or WIth Block variable is not set.  Why here and not after I compile. How am I suppsoe to debug this?
0
Nelmarcas
Asked:
Nelmarcas
  • 5
  • 3
1 Solution
 
mcriderCommented:
Try putting:

   Option Explicit

In the Declarations Section of all of your forms and modules...


Cheers!
0
 
tkuppinenCommented:
Run the application in VB again and try to recreate the exact spot where the error occurs.  You may find that you are missing an object declaration somewhere after all.  Compilation does not necessarily catch all errors, if it did there would be no such thing as run-time erros in VB.
0
 
NelmarcasAuthor Commented:
True.  

The error still occured after I made sure that the Option Explicit Statement was at the head of all my objects.

Unfortunately this is where it happened:

Public Function Add(TheContainer As Object) As Long
Dim ps            As rdoQuery
Dim rs            As rdoResultset
Dim SQL           As String
Dim RetCode       As Long
Dim TheAddressID  As Long

  On Error GoTo AddressAddError

  ReturnCode = 0
  Screen.MousePointer = vbHourglass
  SQL = " execute Global..Add_Address " & _
            " 0 ," & _
            " 'Adding' , " & _
            "'Adding' , " & _
            "'Adding' , " & _
            "'Adding' , " & _
            "'Adding' , " & _
            "'Adding' , " & _
            "'Adding' , "
  SQL = SQL & "'Ad' , " & _
            "'Adding' , " & _
            "'Add' , " & _
            "'Add' , " & _
            "'XXX' "
 
  Set ps = Rover.TheConnection.CreatePreparedStatement("MyPs", SQL)
  ps.RowsetSize = 1
 
  Set rs = ps.OpenResultset(rdOpenForwardOnly)

  TheAddressID = rs(0)'HERE!!!!!!!
 
'here is where I get the error that the Object Collection: Couldn't find item indicated by text occurs.  Funny it runs on my workstation just fine.  But On my partners it coughs. ANy ideas???



  rs.Close
  ps.Close
 
  'Rover.TheConnection.rdoQuery("MyPs").Close
  RetCode = Edit(TheAddressID, TheContainer)
  If RetCode Then
    Add = TheAddressID
  Else
    Add = 0
  End If
 
  Screen.MousePointer = vbDefault
 
  Exit Function
 
AddressAddError:
  Rover.CBPErr.Number = Err.Number
  Select Case Rover.CBPErr.Action
  Case vbAbort
    Add = False
    Exit Function
  Case vbRetry
    Resume
  Case Else
    Resume Next
  End Select
End Function
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
tkuppinenCommented:
Try adding the line set rs = new rdo.resultset before the line giving you the error

0
 
tkuppinenCommented:
Sorry add that line before your current set rs line
0
 
NelmarcasAuthor Commented:
Nope, VB wouldn't allow me to do that.
0
 
tkuppinenCommented:
The line should have read
set rs = new rdoResultset '(no dot)

But why wouldn't VB allow you to do that?
0
 
NelmarcasAuthor Commented:
Invalid use of New Keyword.
0
 
tkuppinenCommented:
From the Vb help file

================================================================================

The following example shows how to create an rdoResultset in code and pass it to an existing RemoteData control:

Option Explicit
Dim qy As rdoQuery
Dim rs As rdoResultset
Dim cn As rdoConnection

Private Sub Form_Load()
Dim SQL As String
Set cn = MSRDC1.Connection

SQL = "{ call ChooseAuthor (?) }"
Set qy = cn.CreateQuery("GetAuthor", SQL)
End Sub


Private Sub Search_Click()
qy(0) = NameWanted.Text
Set MSRDC1.Resultset = qy.OpenResultset( _
   rdOpenStatic, rdConcurReadOnly)

End Sub



Try this syntax and see what happens
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now