Runtime error 91, Object variable not set or with block variable not set

just3082
just3082 used Ask the Experts™
on
Everytime I try and run my app on another PC I get this error.
Am using Visual Studio 6, SP5. Button I click on to get error is "Next form"

Private Sub Command1_Click()
DBSAR.Show
End Sub

JamieJ
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006

Commented:
then next form is not loaded or you have some controls that are initilizing on that form that need something else

tryassuming DBSat is your form

Private Sub Command1_Click()
  Load DBSAR
  DBSAR.Show
End Sub

else give some specifics

Author

Commented:
It runs fine when I make an EXE and run it on the machine I created the app in.

Made the changes you suggested and get the same error. Here is the code for DBSAR,
I can't find anywhere that is missing anything.

Private Sub cmdclickeditdiagrams_Click()
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Load Form6
Form6.Show
End Sub

Private Sub printform_Click()
Dim i As Integer
Printer.Copies = 1
For i = 0 To SSTab1.Tabs - 1
SSTab1.Tab = i
Me.printform ' or form1.printform
Next i
Unload Me
End Sub

Private Sub discharge_Click()
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Form1.Show
End Sub

Private Sub Form_initialize()
Text13.Text = Format(Now(), "mm/dd/yy")
End Sub
Private Sub updatecurrentrecord_Click()
On Error GoTo UpdateErr

  datPrimaryRS.Recordset.UpdateBatch adAffectAll
  Exit Sub
UpdateErr:
  MsgBox Err.Description
End Sub

Private Sub Form_Load()
   datPrimaryRS.Recordset.AddNew
              End Sub
   
 


Private Sub Form_Unload(Cancel As Integer)
  Screen.MousePointer = vbDefault
End Sub
Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
  'This is where you would put error handling code
  'If you want to ignore errors, comment out the next line
  'If you want to trap them, add code here to handle them
  MsgBox "Data error event hit err:" & Description
End Sub

Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  'This will display the current record position for this recordset
  datPrimaryRS.Caption = "Record: " & CStr(datPrimaryRS.Recordset.AbsolutePosition)
End Sub

Private Sub cmdDelete_Click()
  On Error GoTo DeleteErr
  With datPrimaryRS.Recordset
    .Delete
    .MoveNext
    If .EOF Then .MoveLast
  End With
  Exit Sub
DeleteErr:
  MsgBox Err.Description
End Sub

Private Sub cmdRefresh_Click()
  'This is only needed for multi user apps
  On Error GoTo RefreshErr
  datPrimaryRS.Refresh
  Exit Sub
RefreshErr:
  MsgBox Err.Description
End Sub

Private Sub cmdUpdate_Click()
  On Error GoTo UpdateErr

  datPrimaryRS.Recordset.UpdateBatch adAffectAll
  Exit Sub
UpdateErr:
  MsgBox Err.Description
End Sub
Private Sub cmdClose_Click()
  Unload Me
End Sub
Private Sub insertimages_Click(index As Integer)
datPrimaryRS.Recordset.UpdateBatch adAffectAll
Load Form3
Form3.Show
End Sub


I tried removing everything that wasn't important.... Hope this helps...

JamieJ
Top Expert 2006
Commented:
look at your ADO settings, have you used the package and deplyment wizard to distribute?

looks like the worng version of ADO libs or a missing reference install the latest mdac 2.7 on the target machine if a normal setup doesn't help
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Commented:
It sounds like you are missing a dll, try making an install package for the application and run it on the second machine.

just3082, please do not ask me more questions thru e-mail, I think it is ok if you let me know you have a new question thru e-mail I do not know for sure. It gives me an unfair advantage.  Especially since I have your source code etc.....
You did not post all the source code in that form so the current experts are going to have a hard time finding the problem.

bruintje was correct I think.

Private Sub tbToolBar_ButtonClick(ByVal Button As Button) '<-- here is the error

Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)'<--- this is what to do to fix you can also delete the whole sub since it is not used

experts I am sorry

just3082 if this fixes your problem, do not accept this as an answer.
dragontooth

Author

Commented:
I apologize for that, I was just worried and did what I thought would get the quickest answer.

In any event, I can't find the Private Sub tbToolBar_ButtonClick you are referring to.

It is not in DBSAR (Form), Or either I had already removed it.

Thanks,

JamieJ
Top Expert 2006

Commented:
if that solves it then just3082 can accept the comment as answer no probs with me

asking questions through mail is something between expert and questioner but should be done without EE

or

on EE without direct mailing only when it's way to difficult to solve then email can be used

another choice is to ignore mail from users and warn in your profile that you're not going to respond and don't do it :) IT WORKS

Author

Commented:
I accepeted bruintje's answer above since installing the latest MDAC solved the issue.

Thanks,

JamieJ
Top Expert 2006

Commented:
if that solve it then thanks for the grade
Good Deal!!

Thanks bruintje! will do.
just3082 you have a hard project still in front of you. I and the others (I am sure) are more than willing to help. I'll be looking when I CAN help.

started on the weekend
dragontooth

Commented:
What do you mean by:
           ' It sounds like you are missing a dll, try making an install package for the application and run it on the second machine'.

I'm having the same problem and the latest version of MDAC did not resolve it.
Shall I use more than one adodc control in the same form
when I am doing like that it is giving error 91
please give me solution for this

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial