PDA

Click to See Complete Forum and Search --> : Incomplete Query


SAMS
Oct 19th, 1999, 04:22 PM
Can someone tell me why i keep getting error for this code? Thks.

"Object variable or With variable not set"

With Data3
.RecordSource = "select * from " & LTrim(Text70.Text) & "'"
.Recordset.MoveFirst
.Refresh
End With

c@lle
Oct 19th, 1999, 07:12 PM
the error is not in the query, but in the object you are using (Data3)

First of all, you need to 'set' the object.

I presume you did:
dim Data3 as adodb.recordset

Now you have to initialize it, by coding:
set Data3 = new adodb.recordset

You can do this right in this part of code, or in the form load event or somewere else.

Clunietp
Oct 19th, 1999, 09:44 PM
if data3 is a db control, then make sure the databasename property is set. After assigning SQL to your recordsource, then refresh, then movefirst. You are moving first then refreshing. the SQL doesn't really execute until you issue a refresh command.

HTH

Tom

SAMS
Oct 20th, 1999, 08:41 AM
Thks guys, for all your help.