Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2008, 06:01 AM
Registered User
 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paul_Tic
Default Help with Microsoft ActiveX Data Control 6

Hi,

I am new to VB6 and am following a sample application. When I setup a ADO data control as described I am getting the following error:

Run-time error 91. Object variable or with block variable not set.

The code is as follows:

UserInfo.Recordset.AddNew

Any help on this would be really appreciated.

Thanks, Paul
 
Old May 19th, 2008, 06:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

Recordset has something or is nothing?? maybe you didn't open it, or the control can't create it..

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 19th, 2008, 08:23 AM
Registered User
 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paul_Tic
Default

Hi gbianchi,

Thanks for the reply but i am still getting the error.

I have specified the connection string and recordset in the properties of the adodc and the code I have on my form is as below:

========================
Private Sub Form_Load()

UserInfo.Recordset.Open
UserInfo.Recordset.AddNew

End Sub
========================
 
Old May 19th, 2008, 08:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

If you comment this line everything works ok? you can see the recordset after the form is shown?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 19th, 2008, 08:42 AM
Registered User
 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paul_Tic
Default

Hi Gonzalo,

Sorry, I dont think that I explained the problem properly. If i comment the line the form opens up ok although I am not displaying the recordset on the form.

I have 2 forms. 1st form is a login form. If the user does not have a login then they click the "Register" button which opens the Register form.

The adodc is on the Register form and the code is executed on the "On load" of the register form.

Hope this explains a little better.

Thanks for your help.

Paul.
 
Old May 19th, 2008, 08:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hey there.. Maybe the recordset is not loaded in the form load method. Better use the show method (you can control how it works using a boolean variable, false in the form load, and true after the show method, and only you execute the show method is the variable is true).

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 19th, 2008, 09:14 AM
Registered User
 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paul_Tic
Default

Hi Gonzalo,

Sorry but I am very new to VB and am lost.

The example that I am trying to replicate is

http://www.vbtutor.net/lesson22.html

Once again, thanks for you help.

Paul
 
Old May 19th, 2008, 09:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Well, the example is a nice way to do it, but not the better.

The example state that you open a recordset when you load the form and add a record in that moment. For example if you cancel, the program just end, keeping open the connection and never canceling the add new or closing the recordset. If you have several connections to that table, that will be a very bad way to do it. You only want to add the record when you have the data. Otherwise the user could be in that screen hours and will forbids others connection (since the add new is active). Also, is always better to have a column with a numeric code to make searches easier.

Anyway, to make it work do something like this:
Code:
'in the top of the form
dim bFirstTime as boolean = true

'in the load event
Private Sub Form_Load()
'nothing

End Sub

Private Sub Form_show()
    If bFirstTime then
        'your code
        ...
        bFirstTime = false
    End If
End Sub
HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 19th, 2008, 10:34 AM
Registered User
 
Join Date: Feb 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Paul_Tic
Default

Hi Gonzalo,

I have managed to get it working ok now.

Thanks for all your help.

Paul





Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me get my first ActiveX Control run? Looney Javascript How-To 0 May 21st, 2005 09:52 AM
PropertyList activex control coder_gig79 VB Components 3 October 6th, 2004 10:32 PM
pls hlp!!! Microsoft ADO Data Control not found x2c4u VB Databases Basics 3 September 29th, 2004 09:42 AM
How do I use an ActiveX Control? ArtDecade VB.NET 2002/2003 Basics 5 September 18th, 2004 03:23 AM
Could not instantiate ActiveX control because the karthey VS.NET 2002/2003 0 July 1st, 2003 05:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.