Object variable or with block variable not set

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2508 Views - Last Post: 03 May 2013 - 04:35 AM Rate Topic: -----

#1 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Object variable or with block variable not set

Posted 09 April 2013 - 07:44 AM

Hello,

I need help about the error "Object variable or with block variable not set", when I try to run my software in the Test Computer.


Please, would you help me?
Is This A Good Question/Topic? 0
  • +

Replies To: Object variable or with block variable not set

#2 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,782
  • Joined: 26-March 09

Re: Object variable or with block variable not set

Posted 09 April 2013 - 09:46 AM

It normally means you're trying to access an object method that hasn't yet been created or is set to nothing.

You need to post the code relating to the issue for us to be able to help you.
Was This Post Helpful? 0
  • +
  • -

#3 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 10 April 2013 - 03:41 AM

View Postmaj3091, on 09 April 2013 - 09:46 AM, said:

It normally means you're trying to access an object method that hasn't yet been created or is set to nothing.

You need to post the code relating to the issue for us to be able to help you.



Okay. I'll do
Was This Post Helpful? 0
  • +
  • -

#4 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 11 April 2013 - 08:41 AM

[quote name='freesix' date='10 April 2013 - 03:41 AM' timestamp='1365590470' post='1834022']
[quote name='maj3091' date='09 April 2013 - 09:46 AM' timestamp='1365526019' post='1833746']
It normally means you're trying to access an object method that hasn't yet been created or is set to nothing.

You need to post the code relating to the issue for us to be able to help you.

-----


The error occurs when I try to connect to the data base to fill it,

it exactly occurs when I click on the command button that has the vb code [ form3.data1.recordset.addnew ]
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Object variable or with block variable not set

Posted 11 April 2013 - 07:12 PM

So, maybe you don't have a data control called data1 on form3. Or maybe you don't have a form called form3.

This post has been edited by BobRodes: 11 April 2013 - 07:12 PM

Was This Post Helpful? 1
  • +
  • -

#6 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 12 April 2013 - 03:33 AM

View PostBobRodes, on 11 April 2013 - 07:12 PM, said:

So, maybe you don't have a data control called data1 on form3. Or maybe you don't have a form called form3.


No I think it's another problem...

I spell out :

In the source machine, all works fine, even compiling has been made succesfully, without any errors. (100% OK)

but in the target machine, in which I'm testing the software that I got the error message, that is

"Object variable or with block variable not set".
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Object variable or with block variable not set

Posted 12 April 2013 - 06:49 PM

Well, the only reason that you would get that error on that line is if there were no Form3 or no Data1.
Was This Post Helpful? 0
  • +
  • -

#8 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,782
  • Joined: 26-March 09

Re: Object variable or with block variable not set

Posted 13 April 2013 - 12:05 AM

View PostBobRodes, on 13 April 2013 - 01:49 AM, said:

Well, the only reason that you would get that error on that line is if there were no Form3 or no Data1.


I've never used the data control (so don't shoot me over this answer Bob ;) ), but could it also be that you're trying to add a record, when the connection that the data control uses hasn't been opened??

This post has been edited by maj3091: 13 April 2013 - 12:06 AM

Was This Post Helpful? 0
  • +
  • -

#9 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 13 April 2013 - 08:25 AM

[/quote]

Well, the only reason that you would get that error on that line is if there were no Form3 or no Data1.

[/quote]


Thank you for all of your answers.


Concerning Form(X) or Data(X), all are very well in place, problem does not come from their.

Sorry !

I forgot to tell, it is exactly when I try to update database by clicking on COMMAND BUTTON that has code "data1.recordset.addnew"

I think that " ADDNEW " that causes this problem !!!


So, How to fix it ?


PS : Have a wonderful Week end
Was This Post Helpful? 0
  • +
  • -

#10 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 16 April 2013 - 03:00 AM

I searched on the web about that, and I found that DATA CONTROL is not very effective for other vb projects, it works so bad in some big projects sometimes. Instead of DATA CONTROL, rather use ADODC CONTROL or code manually all instructions of your project.

skim this page http://www.vbforums....e-not-set-(VB6)

---

When I still was at University, our teacher also told us about this malfunction of DATA Control (or some database VB Controls).
I remember he suggested us to use vb codes/instructions instead of any VB 6 controls related to database connection (Data / ADO), because of the same matter that what I read in the web.

They are not efficient !!!

But I have not reasonably plenty of time to take a look at school's syllabus.
3 years ago, dig up a syllabus that I classed ARCHIVE !!!

DUST !!! - I hate !!!


I'll try to code it manually and I'll be back if it's fine or not.



Thanks a lot !
Was This Post Helpful? 0
  • +
  • -

#11 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Object variable or with block variable not set

Posted 16 April 2013 - 09:27 PM

Well, I wasn't going to tell you that, but I completely agree. Since you're going to go that way, let me give you a bit of information. First, set a reference to Microsoft Activex Data Objects, latest version you have. Then, investigate the Connection object and the Recordset object. You'll need to create one of each. Set your connection string (have a look at www.connectionstrings.com) and open your connection. Then use the recordset Open method, using the connection object and a SQL string. You'll need to create a Sub called FillFields (or something like it, that's the name I use) that manually populates the text boxes on your screen, and another Sub called EmptyFields for when you're going to add. Then, I prefer to avoid the Recordset update method, personally. I use SQL Action queries (Insert and Update commands) with an ADO Command object. But you can use the Update command; just make sure that you have an updatable CursorType.

Good luck! Post back if you have trouble.
Was This Post Helpful? 0
  • +
  • -

#12 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 27 April 2013 - 11:17 AM

PROBLEM's SOLVED !!!


It was my own fault, I didn't explain you very well what was exactly happened while execution of my software.

So sorry about it !!!


I explain now :


Start over.


Firstly when I executed it in the target machine, I saw 3 error messages that appeared one after one inside dialog boxes :


The first one I could read while execution was :

" Run-time error, Class not registered. Looking for object with CLSID : {00000010-0000-0010-8000-00AA006D2EA4} " , then after clicking on OK button, the second appears



The second one was : a error message related to the path of my database; (Sorry I'm using french version of visual basic 6)

this error message was in french, obviously ! ; but I always can hand it to you by translating.

it said : "the path to find my database file (exemple.mdb) is incorrect, So I need to make sure that the path's name is correct";

and below this message I could read again the path of my database that I set to the databasename property of DATA1 Control,

this path was "D:\Francis\ICT\Project\Visual BASIC\VB 6\2. Gestionnaire de FIDELES (EJCSK-Paroisse LUKUNGA)\BD_FIDELES.mdb"


then after clicking on OK button the third appears



and the third error message (the last one) was : "Run time error '91' Object Variable Or With Block Variable Not Set"

then after clicking on OK button, the software shuting down.


========

During my postes, I just posted the first and the last one, I didn't post the second due to my ignorance.

I thought it's just a small problem, cause it's a error message related to the path of my data base, therefore I ignored it as I knew that I should merely modify the path in the DATA1 control,

I didn't think this could be the source of the third error message [Run time error '91' Object Variable Or With Block Variable Not Set]


I completely forgot that in programming YOU MUST BE L O G I C , then EXTREMELY L O G I C when you're programming;

it's also for this reason that we firstly learn PROGRAMMING LOGIC (ALGORITHMIC) before learning any other PROGRAMMING LANGUAGES !!!



and I also forgot that Microsoft Developpers that built vb6 are not insane to display us ONE after ONE the error messages that your project has;




I just should have followed this logic (this order) before posting my error messages in the forum.


========


The first one has been resolved following your advices and recommandations. Thank you for all users helped me !!!


the second one, I didn't post it, I just ignored it.


I fast jumped to the third, and when you gave me many ways to solve this (ADO Control, www.connectionstrings.com,...),

I said to myself that now I have many things to do, a lot of things to fix in this project;

So, I was disappointed for all sacrifices I've done for this project,

Let me be honestly with you : I even hadn't started yet to look into web-sites and others solutions you gave.

I was so unhappy to allow all my time on something I already allowed plenty of time in the past...


Coding, looking for the right instruction to set in the right place, to make working your software, it's not easy...

until all of your project works very fine in the source machine... It's not easy also !!!




and What about DEPLOYMENT !!!



Like says this Microsoft link (My link) :

"Many developers spend lots of time and effort to develop an application, and then they spend little time or no time to package and to test the application on other computers. This is a common mistake. It is best to budget time into your development schedule for packaging and for testing your application. Consider which operating system versions and which configurations you will support for your application, and budget time for testing the application on those configurations."



==========

RESOLUTION
----------

In brief cause I talked too much.


I left this project for 3 days,

and then the fourth day, I woke up in the morning and Just by intuition, I tried to solve the second error message (which is related to the path of database); as the thrid error, with many ways you suggested me, I was tired to touch it.

when I finished to solve it, I executed my app. just for testing, I was expecting to see the third error message as I hadn't solved it yet, ...but suddenly I didn't see it...


The third that I even had not solved yet HAS DISAPPEARED !!!


I was SO SO GLAD !!!


I was expecting to see the third error message, but I didn't see.


I can only assume it was the second error message that provoked the third.



for now, all works fine in the target machine as well as in the source machine. (NO RUN-TIME ERROR MESSAGEs // NO ERROR MESSAGE DUE TO DEPLOYMENT (DLL or CONTROL missing)


SO GOOD !!! Programming is VERY WONDERFUL !!! (Only when you finish your project as you expected -- but when you start DEBUGGING... Programming becomes TOTALLY B I T T E R !!!!!!




Now what's remain is, Just fixing some small problems regarding users' entries (Textbox); as like programming says : Users are not clever, you need to make sure that users will enter ONLY what the software expect from them.


==========


Thank you for everything you've done for me,

...your time, your expertise, your urge to share what you have !!!


I thank personally everybody who have contributed for helping me.


meanwhile, if I meet a problem, I'll be back.




and, When I'll end this, I'll post this EXE application HERE.




Have a very wonderful day !
Was This Post Helpful? 0
  • +
  • -

#13 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Object variable or with block variable not set

Posted 28 April 2013 - 10:44 AM

À l'égard des erreurs françaises, ce n'est pas la peine de les traduire. :)
Was This Post Helpful? 0
  • +
  • -

#14 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 29 April 2013 - 02:59 AM

:surrender:

vous parlez aussi le Francais ??? :bigsmile:

Vous auriez du me le dire depuis..., pour n'est pas passer mon temps a ecrire en anglais !!!

Et ecrire englais pour un Francophone signifie : (D'abord penser en francais et puis commencer a traduire sa pensEe en anglais...); tache assez diffcile lorsqu'on debute la langue anglaise, mais des lorsqu'on a acquit cependant un bon niveau, tout de vient comme de l'eau a boire !!!

Je reposterai un autre message plutard car je suis un petit peu occupE en ce moment.



Merci a vous et Plein de bonne chose :bananaman:
Was This Post Helpful? 0
  • +
  • -

#15 freesix  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 30-March 13

Re: Object variable or with block variable not set

Posted 30 April 2013 - 07:02 AM

...also, with what happened to me, 

now I understand why people don't prefer to use any Data base tools of VB6 (DATA, ADO...),
they only like TO CODE MANUALLY all instructions.

Why people say that ???   We just need to LOOK at it
---
Microsoft's developer that created vb6 are not insane to make several ways to build your database vb 6 project in chosing DATA objects or Coding manually
whether they had not thought a lot about it, they should have done only one way to make your database project, But if they have given us many ways...  
I think and I'm sure they intended to Help US.

and programming language like Visual basic with ALL ToolsBox and objects, are not made to complicate life to developers certainly,
are mirely to make easier development of applications, in brief TO GO FAST when you're building your project...


But, why people don't like them ???
they suggest others to code manually all instructions, rathen than use tools that vb created to help developers !!!


I know why !!!; Developers are lazy (like said my teacher), 
we don't spend our time to look for
DEEPLY, we only choose what we see the first one when we're looking for solutions... (sorry, it's a personal idea !!!)

We don't search a lot of !!!

What's funny is : I searched on the web and I found that everybody suggests to abandon vb DATA and ADODC, and they advise to Code manually...
only Microsoft itself that suggests to use VB Tools (DATA and ADODC)...

it's GOOD coding manually, you'll gain high skills, BUT sometimes we're
running out time, we only need project be delivered on time
this is why Microsoft created these vb Tools (objects)



DATA object and ADODC are not wrong !!!   

and yet, Are very very GOOD !!!  helping YOU and ME developers, to go fast with our Project.


---

SOLUTION
--------

The only solution when you use VB Database objects (DATA, ADODC) is : 

YOU NEED JUST TO CHOOSE the RIGHT Microsoft DAO Library (Data Access Object), (THE APPROPRIATE  DLL) [*.DLL] for packaging with, while you're packaging your project,
cause NOT ALL controls are automatically included in the package, as THEY ARE NOT automatically referenced in the
project by PDW...


Therefore, YOU NEED TO DO IT MANUALLY by selecting them, going to PROJECT menu, / REFERENCIES / and then choosing THE RIGHT REFERENCE to include it in your project in order to be packed within while PDW will package your project.

---
PS : How to know which REFERENCE is going with my project?   See www.MICROSOFT.com  by typing your error message in the Searching box.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2