14 Replies - 4316 Views - Last Post: 28 March 2012 - 07:27 AM Rate Topic: -----

#1 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 02:31 AM

Im trying to finish my project and im at my last phase But when i run the program it sez
"Error 91 object variable or with block variable not set"

this error appears on the search command found in form2 here is the whole code:

Sub searchingthelist()  
[color="#FFA500"]If Not rs.EOF Then[/color]       <<<<< [color="#FF0000"]This is where its making an error[/color] 
    ListView1.ListItems.Clear
    rs.MoveFirst
    Do While Not rs.EOF
    Set Item = ListView1.ListItems.Add(, , rs!LastName)
    Item.SubItems(1) = rs!FirstName
    Item.SubItems(2) = rs!Company
    Item.SubItems(3) = rs!StreetAddress
    Item.SubItems(4) = rs!City
    Item.SubItems(5) = rs!Region
    Item.SubItems(6) = rs!ZipCode
    Item.SubItems(7) = rs!HomePhone
    Item.SubItems(8) = rs!WorkPlace
    rs.MoveNext
    Loop
    Else
    ListView1.ListItems.Clear
End If
    rs.Close
    Set rs = Nothing
End Sub

Sub search()
If comb.Text = "LastName" Then
Set rs = New ADODB.Recordset
rs.Open "select * from table_save where LastName like '" & txtSearch.Text & "%';", cn, adOpenKeyset, adLockOptimistic
Form2.searchingthelist
ElseIf comb.Text = "FirstName" Then
Set rs = New ADODB.Recordset
rs.Open "select * from table_save where Firstname Like '" & txtSearch.Text & "%';", cn, adOpenKeyset, adLockOptimistic
Form2.searchingthelist
End If
End Sub
Private Sub Additional_Click()
Frame5.Width = 6015
Frame5.Height = 2295
End Sub

Private Sub asa_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from Room_no", ae, adOpenKeyset, adLockOptimistic
rs!Roomno = RN3.Text
rs!Deluxe = z.Text
rs!ExtraBed = x.Text
rs!ExtraPerson = k.Text
rs.Close
Set rs = Nothing
Form2.List_records3
End Sub

Private Sub C_Click()
On Error Resume Next
If C = "Lovely(2)" Then AP.Text = "1500"
If C = "Sweetie(4)" Then AP.Text = "2250"
If C = "Honey(6)" Then AP.Text = "3000"
If C = "Lovely(2)" Then total.Text = 1500 * NOD.Text
If C = "Sweetie(4)" Then total.Text = 2250 * NOD.Text
If C = "Honey(6)" Then total.Text = 3000 * NOD.Text
End Sub


Private Sub C1_Click()
If C1.Text = "Food" Then
Form2.C2.AddItem "Cake"
Form2.C2.AddItem "etc."
Else
Form2.C2.AddItem "Television"
Form2.C2.AddItem "Radio"

End If
End Sub

Private Sub C2_Click()
If C2.Text = "Cake" Then A.Text = 250
If C2.Text = "etc." Then A.Text = "350"
If C2.Text = "Television" Then A.Text = "500"
If C2.Text = "Radio" Then A.Text = "150"
End Sub

Private Sub Check15_Click()
If Check15.Value = 1 Then
NOP.Enabled = True
Else
NOP.Enabled = False
NOP.Text = ""

End If
End Sub

Private Sub Check2_Click()
If Check2.Value = 1 Then
z.Text = "980"
Else
z.Text = ""
End If
End Sub

Private Sub Check3_Click()
If Check3.Value = 1 Then
b.Text = 250
v.Visible = True
Else
v.Text = ""
v.Visible = False
End If
End Sub

Private Sub Check4_Click()
If Check4.Value = 1 Then
j.Text = 250
NOP.Visible = True
Else
NOP.Text = ""
NOP.Visible = False
End If
End Sub

Private Sub Clear_Click()
 BI.Text = ""
 BD.Text = ""
LN.Text = ""
 FN.Text = ""
 CI2.Text = ""
 CO.Text = ""
 RN2.Text = ""
 C.Text = ""
 NOD.Text = ""
 NOP.Text = ""
AP.Text = ""
total.Text = ""
End Sub

Private Sub cmdDelete_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from table_save where LastName='" + Trim(txtLN.Text) + " '", cn, adOpenKeyset, adLockPessimistic
rs.Clone
msg1 = MsgBox("Are you sure you want to delete this?", vbokcanel, "delete")
If msg1 = vbOK Then
rs.Delete
Set rs = Nothing
MsgBox "Deleted!"
Form2.List_records
txtLN.Text = ""
txtFN.Text = ""
txtComp.Text = ""
txtSA.Text = ""
txtCity.Text = ""
cmbR.Text = ""
txtZC.Text = ""
txtHP.Text = ""
txtWP.Text = ""
End If
End Sub

Private Sub cmdSave1_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from table_save", cn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!LastName = txtLN.Text
rs!FirstName = txtFN.Text
rs!Company = txtComp.Text
rs!StreetAddress = txtSA.Text
rs!City = txtCity.Text
rs!Region = cmbR.Text
rs!ZipCode = txtZC.Text
rs!HomePhone = txtHP.Text
rs!WorkPlace = txtWP.Text
rs.Update
MsgBox "Saved"
rs.Close
Set rs = Nothing
Form2.List_records
txtLN.Text = ""
txtFN.Text = ""
txtComp.Text = ""
txtSA.Text = ""
txtCity.Text = ""
cmbR.Text = ""
txtZC.Text = ""
txtHP.Text = ""
txtWP.Text = ""
txtLN.Enabled = False
txtFN.Enabled = False
txtComp.Enabled = False
txtSA.Enabled = False
txtCity.Enabled = False
cmbR.Enabled = False
txtZC.Enabled = False
txtHP.Enabled = False
txtWP.Enabled = False
cmdSave1.Enabled = False
cmdDelete.Enabled = False
cmdUpdate.Enabled = False

End Sub
Sub List_records()
Set rs = New ADODB.Recordset
rs.Open " select *from table_save", cn, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
ListView1.ListItems.Clear
rs.MoveFirst
Do While Not rs.EOF
Set Item = ListView1.ListItems.Add(, , rs!LastName)
Item.SubItems(1) = rs!FirstName
Item.SubItems(2) = rs!Company
Item.SubItems(3) = rs!StreetAddress
Item.SubItems(4) = rs!City
Item.SubItems(5) = rs!Region
Item.SubItems(6) = rs!ZipCode
Item.SubItems(7) = rs!HomePhone
Item.SubItems(8) = rs!WorkPlace
rs.MoveNext
Loop
Else
ListView1.ListItems.Clear
End If
rs.Close
Set rs = Nothing
End Sub
Sub List_records2()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open " select *from Guest_ID", ar, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
ListView2.ListItems.Clear
rs.MoveFirst
Do While Not rs.EOF
Set Item = ListView2.ListItems.Add(, , rs!BookingID)
Item.SubItems(1) = rs!BookingDate
Item.SubItems(2) = rs!GuestName
Item.SubItems(3) = rs!Name
Item.SubItems(4) = rs!CheckIn
Item.SubItems(5) = rs!CheckOut
Item.SubItems(6) = rs!RoomNumber
Item.SubItems(7) = rs!RateType
Item.SubItems(8) = rs!NumberOfDays
Item.SubItems(9) = rs!NumberOfPersons
Item.SubItems(10) = rs!Paid
rs.MoveNext
Loop
Else
ListView2.ListItems.Clear
End If
rs.Close
Set rs = Nothing
End Sub
Private Sub cmdSearch_Click()
Form3.Show vbModal
Frame3.Height = 6615
Frame3.Width = 6015
End Sub

Private Sub cmdUpdate_Click()
Set rs = New ADODB.Recordset
rs.Open "select * from table_save where LastName='" + Trim(txtLN.Text) + " '", cn, adOpenKeyset, adLockPessimistic
rs!LastName = txtLN.Text
rs!FirstName = txtFN.Text
rs!Company = txtComp.Text
rs!StreetAddress = txtSA.Text
rs!City = txtCity.Text
rs!Region = cmbR.Text
rs!ZipCode = txtZC.Text
rs!HomePhone = txtHP.Text
rs!WorkPlace = txtWP.Text
rs.Update
rs.Close
Set rs = Nothing
Form2.List_records
End Sub

Private Sub Combo2_Change()
If "single" = 1000 Then Text11.Text = 1000
End Sub

Private Sub comb_Change()
If comb.Text = "Name" Then
Set rs = New ADODB.Recordset
rs.Open "select * from table_save where LastName like '" & txtSearch.Text & "%';", cn, adOpenKeyset, adLockOptimistic
Form2.searchingthelisthelist
End If
End Sub

Private Sub Command1_Click()
txtLN.Text = ""
txtFN.Text = ""
txtComp.Text = ""
txtSA.Text = ""
txtCity.Text = ""
cmbR.Text = ""
txtZC.Text = ""
txtHP.Text = ""
txtWP.Text = ""
txtLN.Enabled = True
txtFN.Enabled = True
txtComp.Enabled = True
txtSA.Enabled = True
txtCity.Enabled = True
cmbR.Enabled = True
txtZC.Enabled = True
txtHP.Enabled = True
txtWP.Enabled = True
cmdSave1.Enabled = True
cmdDelete.Enabled = True
cmdUpdate.Enabled = True

End Sub
Private Sub DTPicker1_Click()
Text1.Text = DTpic
End Sub

Private Sub Command3_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from Guest_ID", ar, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!BookingID = BI.Text
rs!BookingDate = BD.Text
rs!GuestName = LN.Text
rs!Name = FN.Text
rs!CheckIn = CI2.Text
rs!CheckOut = CO.Text
rs!RoomNumber = RN2.Text
rs!RateType = C.Text
rs!NumberOfDays = NOD.Text
rs!NumberOfPersons = NOP.Text
rs!Paid = AP.Text
rs.Update
MsgBox "Saved"
rs.Close
Set rs = Nothing
Form2.List_records2
End Sub

Private Sub Command4_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from Guest_ID where BookingDate='" + Trim(BD.Text) + " '", ar, adOpenKeyset, adLockPessimistic
rs.Delete
msg1 = MsgBox("Are you sure you want to delete this?", vbokcanel, "delete")
If msg1 = vbOK Then
rs.Delete
Set rs = Nothing
MsgBox "Deleted!"
Form2.List_records2
BI.Text = ""
BD.Text = ""
LN.Text = ""
CI2.Text = ""
CO.Text = ""
RN2.Text = ""
C.Text = ""
NOD.Text = ""
NOP.Text = ""
AP.Text = ""
End If
End Sub

Private Sub Command5_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from Guest_ID where BookingDate='" + Trim(BD.Text) + " '", ar, adOpenKeyset, adLockPessimistic
rs!BookingID = BI.Text
rs!BookingDate = BD.Text
rs!GuestName = LN.Text
rs!Name = FN.Text
rs!CheckIn = CI2.Text
rs!CheckOut = CO.Text
rs!RoomNumber = RN2.Text
rs!RateType = C.Text
rs!NumberOfDays = NOD.Text
rs!NumberOfPersons = NOP.Text
rs!Paid = AP.Text
rs.Update
rs.Close
Set rs = Nothing
Form2.List_records2
End Sub

Private Sub Command6_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from Guest_ID", ar, adOpenKeyset, adLockOptimistic
rs!BookingID = BI.Text
rs!BookingDate = BD.Text
rs!GuestName = LN.Text
rs!Name = FN.Text
rs!CheckIn = CI2.Text
rs!CheckOut = CO.Text
rs!RoomNumber = RN2.Text
rs!RateType = C.Text
rs!NumberOfDays = NOD.Text
rs!NumberOfPersons = NOP.Text
rs!Paid = AP.Text
rs.Update
rs.Close
Set rs = Nothing
Form2.List_records2
End Sub

Private Sub Command7_Click()
On Error Resume Next
total.Text = Val(AP.Text * NOD.Text) + Val(NOP.Text * 250)
End Sub

Private Sub Command8_Click()
NOP.Text = 1 + 1
End Sub

Private Sub D_Click()
CO.Text = D.Value
End Sub

Private Sub DB_Change()
NOD.Text = DB.Text
End Sub

Private Sub Done_Click()
Frame5.Width = 0
Frame5.Height = 0
End Sub

Private Sub DT_Click()
CD.Text = DT.Value
BD.Text = DT.Value
CI2.Text = DT.Value
End Sub
Private Sub Form_Load()
txtLN.Enabled = False
txtFN.Enabled = False
txtComp.Enabled = False
txtSA.Enabled = False
txtCity.Enabled = False
cmbR.Enabled = False
txtZC.Enabled = False
txtHP.Enabled = False
txtWP.Enabled = False
cmdSave1.Enabled = False
cmdDelete.Enabled = False
cmdUpdate.Enabled = False
cmbR.AddItem "NCR"
cmbR.AddItem "CAR"
cmbR.AddItem "Region I"
cmbR.AddItem "Region II"
cmbR.AddItem "Region III"
cmbR.AddItem "Region IVA"
cmbR.AddItem "Region IVB"
cmbR.AddItem "Region V"
cmbR.AddItem "Region VI"
cmbR.AddItem "Region VII"
cmbR.AddItem "Region VIII"
cmbR.AddItem "Region X"
cmbR.AddItem "Region XI"
cmbR.AddItem "Region XII"
cmbR.AddItem "Region ARMM"
Form2.List_records
Form2.List_records2
Form2.List_records3
C.AddItem "Lovely(2)"
C.AddItem "Sweetie(4)"
C.AddItem "Honey(6)"
comb.Clear
comb.AddItem "LastName"
comb.AddItem "FirstName"
Form2.searchingthelist
Set rs = New ADODB.Recordset
rs.Open "select * from table_save", cn, adOpenKeyset, adLockOptimistic
Form2.Show vbModal
End Sub

Private Sub k_Change()
A.Text = Val(z.Text) + Val(x.Text) + Val(k.Text)
End Sub

Private Sub l_Change()
k.Text = Val(l.Text) * Val(j.Text)
End Sub

Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
With Item
    txtLN.Text = .Text
    txtFN.Text = .SubItems(1)
    txtComp.Text = .SubItems(2)
    txtSA.Text = .SubItems(3)
    txtCity.Text = .SubItems(4)
    cmbR.Text = .SubItems(5)
    txtZC.Text = .SubItems(6)
    txtHP.Text = .SubItems(7)
    txtWP.Text = .SubItems(8)
    FN.Text = .SubItems(1)
    LN.Text = .Text

End With
End Sub

Private Sub Text10_Change()
Text11.Text = Val(Text10.Text) * Val(Text11.Text)
End Sub

Private Sub Text11_Change()
On Error Resume Next
End Sub

Private Sub Text2_Change()
Text10.Text = Text2.Text
End Sub

Private Sub Text3_Change()
Text9.Text = Text3.Text
End Sub

Private Sub ListView2_ItemClick(ByVal Item As MSComctlLib.ListItem)
With Item
BI.Text = .Text
BD.Text = .SubItems(1)
LN.Text = .SubItems(2)
FN.Text = .SubItems(3)
CI2.Text = .SubItems(4)
CO.Text = .SubItems(5)
RN2.Text = .SubItems(6)
C.Text = .SubItems(7)
NOD.Text = .SubItems(8)
NOP.Text = .SubItems(9)
AP.Text = .SubItems(10)

End With
End Sub

Private Sub NOD_Change1()
On Error Resume Next
: If C = "Lovely(2)" Then total.Text = (AP.Text * 1500)
: If C = "Sweetie(4)" Then AP.Text = (2250 * NOD.Text)
: If C = "Honey(6)" Then AP.Text = (3000 * NOD.Text)

End Sub

Private Sub NOD_Change2()
If NOD.Text = NOD.Text Then
total.Text = NOD.Text * AP.Text
End If
End Sub
Private Sub ListView3_ItemCheck(ByVal Item As MSComctlLib.ListItem)
With Item
RN3.Text = .Text
z.Text = .SubItems(1)
v.Text = .SubItems(2)
NOP.Text = .SubItems(3)
A.Text = .SubItems(4)
End With
End Sub

Private Sub NOD_Change()
total.Text = Val(AP.Text) * Val(NOD.Text)
End Sub

Private Sub NOP_Change()
k.Text = Val(NOP.Text) * Val(j.Text)
End Sub

Private Sub RN_Change()
RN2.Text = RN.Text
End Sub

Private Sub RN2_Change()
RN3.Text = RN2.Text
End Sub
Private Sub SV_Click()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open "select * from Table_record", ae, adOpenKeyset, adLockOptimistic
rs.AddNew
rs!Roomno = RN3.Text
rs!Deluxe = z.Text
rs!ExtraBed = v.Text
rs!ExtraPerson = NOP.Text
rs!Additionals = A.Text
rs.Update
MsgBox "Saved"
rs.Close
Set rs = Nothing
Form2.List_records3
End Sub
Sub List_records3()
On Error Resume Next
Set rs = New ADODB.Recordset
rs.Open " select *from Table_record", ae, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
ListView3.ListItems.Clear
rs.MoveFirst
Do While Not rs.EOF
Set Item = ListView3.ListItems.Add(, , rs!Roomno)
Item.SubItems(1) = rs!Deluxe
Item.SubItems(2) = rs!ExtraBed
Item.SubItems(3) = rs!ExtraPerson
Item.SubItems(4) = rs!Additionals
rs.MoveNext
Loop
Else
ListView3.ListItems.Clear
End If
rs.Close
Set rs = Nothing
End Sub

Private Sub Text1_Change()
Form2.search
End Sub

Private Sub txtSearch_Change()
Form2.search
End Sub

Private Sub v_Change()
x.Text = Val(v.Text) * Val(b.Text)
End Sub

Private Sub x_Change()
A.Text = Val(z.Text) + Val(x.Text) + Val(k.Text)
End Sub

Private Sub z_Change()
A.Text = Val(z.Text) + Val(x.Text) + Val(k.Text)
End Sub


This post has been edited by BobRodes: 26 March 2012 - 02:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Error 91 object variable or with block variable not set: Help pls

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 03:13 AM

It's basically telling you that the object rs hasn't been instantiated (created) or it isn't in the scope of form2.

Look at where you create the object as a starting point.
Was This Post Helpful? 0
  • +
  • -

#3 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 03:20 AM

I dont get what you mean but i have tried Doing this it runs but the search text doesn't work because i placed it their.

Set rs = New ADODB.Recordset
rs.Open "select * from Table_record", ae, adOpenKeyset, adLockOptimistic

If Not rs.EOF Then <<<<< This is where its making an error
ListView1.ListItems.Clear
rs.MoveFirst
Do While Not rs.EOF
Set Item = ListView1.ListItems.Add(, , rs!LastName)
Item.SubItems(1) = rs!FirstName
Item.SubItems(2) = rs!Company
Item.SubItems(3) = rs!StreetAddress
Item.SubItems(4) = rs!City
Item.SubItems(5) = rs!Region
Item.SubItems(6) = rs!ZipCode
Item.SubItems(7) = rs!HomePhone
Item.SubItems(8) = rs!WorkPlace
rs.MoveNext
Loop
Else
ListView1.ListItems.Clear
End If
rs.Close
Set rs = Nothing
End Sub
Was This Post Helpful? 0
  • +
  • -

#4 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 03:51 AM

please help I really ned to finish this tonight help please
Was This Post Helpful? 0
  • +
  • -

#5 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 03:58 AM

@maj
does making a module cover all the forms i have a module if rs is not working then my system would not run its only in this particular phrase im getting an error.
Was This Post Helpful? 0
  • +
  • -

#6 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 04:59 AM

If you have defined as public in a module then it would cover the forms also.

At a quick glance, I can see that most of your subs have On Error Resume Next at the top of them, so it would resume after an error, which may hide the error in other parts of your program.

I'm assuming from your earlier posts, you're now creating a new recordset and executing the query in the same function??

If so, put a breakpoint at the top of the code in the command button where you get the error and you step through, look at the RS object, what happens?
Was This Post Helpful? 0
  • +
  • -

#7 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 05:33 AM

Im really sorry i can't understand what you're saying right now I havn't had a sleed for 4 days because of this. uhmm are you implying that i should put On error resume next? when i put that on top my VB Does not responds and i have to end process it.
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 06:56 AM

No, I didn't suggest you should put that at all.

Do you know how to add breakpoints and debug applications?
Was This Post Helpful? 0
  • +
  • -

#9 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 07:00 AM

no i don't how do you do that?
Was This Post Helpful? 0
  • +
  • -

#10 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 07:10 AM

You might want to have a read through the following.

It will explain things a lot better than I will.

It's a very useful thing to know and will help you in future to debug your own problems.
Was This Post Helpful? 0
  • +
  • -

#11 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 26 March 2012 - 02:59 PM

What maj says is very true. However, you might try putting a "Dim rs as ADODB.Recordset" at the top of your Form2 and seeing if that solves your problem.
Was This Post Helpful? 0
  • +
  • -

#12 kael6590  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 26-February 12

Re: Error 91 object variable or with block variable not set: Help pls

Posted 27 March 2012 - 09:28 PM

What maj says is very true. However, you might try putting a "Dim rs as ADODB.Recordset" at the top of your Form2 and seeing if that solves your problem.

its still not working, tried everything but still the same but in my form3 my search works only in form2 it does not work.

Edited by Dogstopper:
Fixed your formatting issue
Was This Post Helpful? 0
  • +
  • -

#13 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 28 March 2012 - 07:11 AM

If you are still not sorted, start by removing ALL "On Error Resume Next" from your code. This is not a way to make errors go away, it's only a way to hide them and make them harder to find.

Once you have that done, post back and explain what your errors are. Give exact error, and exact line of code that causes it.
Was This Post Helpful? 0
  • +
  • -

#14 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 28 March 2012 - 07:21 AM

As a follow up to Bob's comment, did you read the link on how to debug?

If so, you should be able to provide more information about the issues instead of "its still not working".

Help us a little, to help you.
Was This Post Helpful? 0
  • +
  • -

#15 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 571
  • View blog
  • Posts: 2,979
  • Joined: 19-May 09

Re: Error 91 object variable or with block variable not set: Help pls

Posted 28 March 2012 - 07:27 AM

As a follow up to Maj's comment, make sure you get those "On Error Resume Next" lines out of there before trying to debug, because they disable the debugger.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1