Solved

please amend this code

Posted on 2002-07-29
4
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

636 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