Solved

please amend this code

Posted on 2002-07-29
4
170 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 50 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Paint/Redraw window while dragging 16 83
using Access 8 76
VBA to find and replace multiline text from VBA modules 8 66
adding "ungroup sheets" to existing vbs code 5 31
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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