Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

please amend this code

Posted on 2002-07-29
4
Medium Priority
?
175 Views
Last Modified: 2010-05-02
Hi,


the following code gives me this error: "Object variable or with block variable not set "

Private Sub Form_Load()
Dim SsqlD  As String


SsqlD = "DELETE * FROM Table1”

Me.Adodc1.LockType = adLockOptimistic
Me.Adodc1.Recordset.Source. = SsqlD

please help by amending this code

asns
0
Comment
Question by:asns
  • 3
4 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7184827
I think you should bind the recordset's recordsource to a recordset and not a string as you are doing. Try making the following changes:


Private Sub Form_Load()
Dim SsqlD  As String
SsqlD = "DELETE * FROM Table1”
Me.Adodc1.Recordset.Source. = SsqlD
Me.Adodc1.Refresh
End sub
-priya

0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7184831
sorry this line ..
Me.Adodc1.Recordset.Source. = SsqlD

should be..
Me.Adodc1.RecordSource = SsqlD
and then the refresh thing..

hope this helps
-priya
0
 
LVL 2

Accepted Solution

by:
priya_pbk earned 200 total points
ID: 7184840
>>I think you should bind the recordset's recordsource to a recordset and not a string as you are doing. Try making the following changes:<<

Pls ignore this in the first suggestion, i was trying somthing else first.

Just to avoid confusion, the code will be:

Private Sub Form_Load()
Dim SsqlD  As String
SsqlD = "DELETE * FROM Table1”
Me.Adodc1.RecordSource = SsqlD
Me.Adodc1.Refresh
End sub

-priya
0
 
LVL 3

Expert Comment

by:sanjaykattimani
ID: 7184868
If you have connection object

ConDb.Execute("DELETE * FROM Table1")

will do the needful.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question