Solved

please amend this code

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now