Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2006, 07:21 PM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default error 91 issues.

OK, I'm at my wits end on this one and cannot find much of any use in MSDN either for some reason - LOL.

This is the code:

Private Sub Command1_Click()
Dim strsearchfor As String, intfound As Integer

strsearchfor = UCase(Text1.Text)
Data1.DatabaseName = "e:\shopkeeper\shopkeeper.mdb"

Data1.Recordset.MoveFirst
intfound = 0

Do While intfound = 0 And Not Data1.Recordset.EOF
If UCase(Data1.Recordset.Fields("homephone").Value) = strsearchfor Then
intfound = 1
Else
Data.Recordset.MoveNext
End If
Loop
If intfound = 0 Then
MsgBox ("Unable to locate the requested phone number"), , "Not Fount"

Else

Dim ssql As String

ssql = "select * from customer where [homephone]= chr(34) & strsearchfor & chr(34)"
Data1.RecordSource = ssql
Data1.Refresh

Text2.Text = Data1.Recordset.Fields("firstname").Value
Text3.Text = Data1.Recordset.Fields("lastname").Value
Text4.Text = Data1.Recordset.Fields("custid").Value
End If
End Sub

When entering phone number into text1 - and clicking on the button - it immediately gives me an error 91 - object variable or with block variable not set. What the heck am I missing here? I'm sure it's something very simple and I'm just not seeing it.

Thanks guys
Steve

 
Old October 30th, 2006, 09:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

i supossed that data1 is a datacontrol.. so you are trying it to look for something.. but you are moving the recordset inside them before you even give it a recordset..

Code:
Private Sub Command1_Click()
Dim strsearchfor As String, intfound As Integer

strsearchfor = UCase(Text1.Text)
Data1.DatabaseName = "e:\shopkeeper\shopkeeper.mdb"

Data1.Recordset.MoveFirst
intfound = 0
try to trace your code and you will see that the highlighted error line is that (well, i think so... if not please tell us where is the error)

HTH

Gonzalo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 91 GVBGVB Excel VBA 2 April 4th, 2008 12:56 AM
error 91 skrj02 Excel VBA 4 May 7th, 2007 11:01 AM
Runtime error 91: Apjong Beginning VB 6 1 June 7th, 2006 09:47 AM
runtime error 91 Perseus Beginning VB 6 2 July 30th, 2005 04:36 AM
Run Time Error '91' derniel VB Databases Basics 1 July 15th, 2005 12:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.