Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Keep Getting "can't Create Object" Error


Hi All

I have recently built a application that reads outlook emails and
extracts email addresses from the body of the mail.

My Problem:

The application works fine on my machine "windows me" but when i run it on a 95 or 98 I get the error:

"Runtime error 429, Axtivex component can't create object"

I can find load's of references to it in MSDN but none that seem to be specific to my problem.

Here is the code where the problem appears:

Dim objOutlook As New outlook.Application
Dim objNameSpace As outlook.NameSpace
Dim objFolder As MAPIFolder
Dim objMail As MailItem
Dim theseMails As Integer
Dim i
Dim messages As String
MsgBox "before set object" This fires ok
amountOfmails = 0
' Get the MAPI name space
Set objOutlook = CreateObject("outlook.Application")

Set objNameSpace = objOutlook.GetNamespace("MAPI")
MsgBox "After set object" I do not get as far as this message


I hope someone can help

Malcolm




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Why Can't Create "Excel.Application" Object Using "CreateObject" Function
Hi there,
I try to create an "Excel.Application" object using CreateObject function, I got "nothing" from the return variable without any error messages, but It works well on another machine that it has same environment settings(include same references setting) on those 2 machine: Win2k/Sp4, VB6/Sp5, Mdac_type2.7, the following is source code snippet:

Public appWorld As Excel.Application
Public wbWorld As Excel.Workbook
Sub Setup()
On Error Resume Next 'ignore errors
Set appWorld = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set appWorld = CreateObject("Excel.Application") 'run it
End If
Err.Clear
End Sub

I got "nothing" from "appWorld", even I remark all of error handle lines, the same result I got, pls help,thanks!
ps: you could reply me to : frankie@sompojapan.com.hk

Debugging For: "ActiveX Component Can't Create Object Error Number: 429"
After successfully logging into client software I receive the error "ActiveX component can't create object Error Number: 429"

I looked at the registry keys that are being called and all the ones with "activex" in the path or title are called successfully.

Where do I start to debug this error?

Help is greatly appreciated.
Thank you.

"Run-time Error '429' ActiveX Component Can't Create Object"
Hello,

I developed my app on a laptop with Windows XP Home. It runs fine. On an earlier version, it ran fine when I installed in on my Windows 2000 desktop. Now, for some reason I get a "Run-time error '429' ActiveX component can't create object" message (see attached image).

I am not using a database. I am using a dll and am registering it using INNO 5 installer. I have manually registered it also, but still get the same Run-time error.

Inno line to register....

Source: "C:Documents and SettingsuserDesktopInstallTools.dll"; DestDir: "{sys}"; Flags: restartreplace sharedfile regserver

The only thing I can remember changing is that I added a picture to my "About" form.

Thoughts?

Runtime Error 429 "ActiveX Component Can't Create Object"
With my chat program, when i clicked "Connect" on one side, error popups saying "Runtime-Error 429 ActiveX Component Can't Create Object"
What should i do???
What should i do?
what caused this error and how do i fix it???
I really need to get my program workin

pls help

thank you!

Run-time Error 429 "ActiveX Component Can't Create Object"
Hi all,

I made a connection to Rational Rose dll in visual basic. In my computer everything works but if I use package&deployment wizard to make run the .exe in another computer it appears the runtime error 429, ActiveX component can't create object?

In target machine I have already installed visual basic runtime environment.

Are there any dll I have to add to the target machine besides dll that have been added by package&deployment wizard?

Sorry for my poor english.

Runtime Error: 429 "ActiveX Component Can't Create Object"
This error is driving me insane.

I ran the fix from msdn, no luck.

My programs run perfect on my computer, and if i send my friend the source, he can run it fine in vb.

Problem is, when i compile them, the only one who can run them, is me!

I thought it had to do with the activex controls microsoft stated in the msdn article.. so deleted every reference to them in my project, no luck.

I started over, Compiling step by step, figuring out whats wrong...

I didn't get passed step 1!

Ok now onto my problem...

I have a Project group, with a standard exe, and a activex dll.
In the dll i have a class file, so i can open up forms, when the exe tells the class to open it, it gives a runtime 429 error, saying "activex compontent can't create object" what does that mean, and how can i fix it?

"Runtime Error-429 ActiveX Component Can't Create Object". For COM+ Comp. On Win2003
Hi There!

Could anybody please help regarding the below issue.

We had a COM+ component deployed on Windows 2000/NT machine it was working fine, I mean when it was being invoked from other machines it was creating object and was serving the purpose.

Recently as an upgrade we moved all the COM+ component from Windows 2000/NT to WINDOWS 2003 and now when we are trying to invoke that component its throwing "Runtime Error-429 ActiveX Component can't create Object".

Client side machines are running Windows XP with SP2, COM+ component was created as a server application. I doubt that it may be because of Windows 2003 security issue but not sure or am I missing something while building that component.

Please help or provide your suggestions.

Thanks in advance.

CreateObject("Outlook.Application") - Error 429 ActiveX Component Can't Create Object
I'm trying to learn how to program with Outlook Express 6 using Visual Basic 5. The problem is with having these couple lines of code:

Option Explicit

Dim Outlook As Object

Sub Main()

Set Outlook = CreateObject("Outlook.Application")

End Sub

I get a Runtime Error 429: ActiveX Component Can't Create Object. Of course obviously my Outlook Express works fine. I've done some heavy duty research on how to solve this problem looking literally everywhere on the internet. Registering the MSIMN.EXE using DOS was one of the solutions. It didn't work. The registry looks like it might be the solution. Over in this key path (HKEY_CLASSES_ROOTCLSID{0006F03A-0000-0000-C000-000000000046}) where Outlook Express is supposed to be located, I noticed it was empty! It is supposed to have InprocHandler32, InprocServer32, LocalServer32, ProgID, Typelib, and VersionIndependentProgID. Both ProgID and VersionIndependentProgID are supposed to have "Outlook.Application" as a string value (REG_SZ) which is required for scripting when you want ActiveX components to create the object for you. I can try typing the values by hand which probably won't work but is there anything else I can use to automatically fill these registry values in without screwing up Outlook Express 6? Possibly a program that registers it and fills in the registry keys for me?

Also, if you don't have the exact solution, I would at least like to know what value you have under HKEY_CLASSES_ROOTCLSID{0006F03A-0000-0000-C000-000000000046}InprocServer32 since the other computer in my house (which isn't mine) has a value of some dll from McAfee, and McAfee is what I don't have.

"ActiveX Component Can't Create Object" Error
People that install my program all get this "ActiveX component can't create object" error. I am pretty sure it's caused by the reference "Microsoft Ooutlook 10.0 object library" (msoutl.olb).

Do I need a liscense or something to distribute this? How can I fix the error?

Thanks

"ActiveX Component Can't Create Object" Error
I am trying to access Outlook Express's address book with some code I found on one of the forums here. The CreateObject function in that code however produces a "ActiveX component can't create object" error (error code 429) when executed.

When I try my own code I get the same error. The code:


Code:
Dim Outlook As Object
Set Outlook = CreateObject("outlook.application")


Which files need to be installed and which version of Outlook Express do I need? (I am using Outlook Express 6) Also, I can't find a reference to outlook.application in the registry which as I understand must be some where in the registry for CreateObject to work. Which files if any do I need to register and how?

BTW:
I searched the internet and the forums here before posting.
And:
When I replace "outlook.application" with "excel.application" for example, just to test the CreateObject function I get no errors.

The code I found on these forums can be found in this thread: http://vbforums.com/showthread.php?s=&threadid=292503

Error 429 "ActiveX Component Can&#039;t Create Object" ???
Hope someone can help - this is doing my head in!

(Dev Env: Win98 VB6.0 SP3)

Ok - I've got an app that works fine on the win98 development machine. When installing on win95 test machine it works ok until suddenly it throws up this Error 429 "ActiveX Component Can't Creat Object"

I'm really new at this and don't know how to debug it... From what I know:

It's the msInet control that's doing it, BUT - it's already successfully executed a couple of commands:

1. "CD /" (to test the ftp connection)
2. "CD /website/test/" (to change to the required directory to transfer to)

The one that fails is a PUT command...??

PLEASE help - I've got a few other bugs in the software which I expected, but this is the one that is really stumping me!

Cheers all,



------------------
Chris Keeble
www.giglist.com
mailto:chris.keeble@giglist.com

Error 429 "ActiveX Component Can&#039;t Create Object" ???
Hope someone can help - this is doing my head in!

(Dev Env: Win98 VB6.0 SP3)

Ok - I've got an app that works fine on the win98 development machine. When installing on win95 test machine it works ok until suddenly it throws up this Error 429 "ActiveX Component Can't Creat Object"

I'm really new at this and don't know how to debug it... From what I know:

It's the msInet control that's doing it, BUT - it's already successfully executed a couple of commands:

1. "CD /" (to test the ftp connection)
2. "CD /website/test/" (to change to the required directory to transfer to)

The one that fails is a PUT command...??

PLEASE help - I've got a few other bugs in the software which I expected, but this is the one that is really stumping me!

Cheers all,



------------------
Chris Keeble
www.giglist.com
mailto:chris.keeble@giglist.com

"ActiveX Component Can Not Create Object" Error
Hi, all...
I have completed my project and used P&D Wizard to create a setup.exe package of the program.

I tried to install the application in other PCs and meet some problems. All the PCs i have tried to installed the application are using Win2000, i also developed the tool in Win2000.

The error message is "ActiveX component can not create the object" in the procedure of registering DLLs during installation of the application.

I only met this problem in some PCs not all of them. However all the PCs are using Win2000.

My program is quiet simple, i added some new components such as CommonDialog box, progressing bar. Since i need to generate a word document, so added a new reference Microsoft Word 9.0 object library. And some simple APIs also used in my program.


Any idea on this ???


Sami.




P.S>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

This is the [Bootstrap Files] in my SETUP LST File

[Bootstrap Files]
File1=@VB6STKIT.DLL,$(WinSysPathSysFile),,,3/26/99 12:00:00 AM,101888,6.0.84.50
File2=@COMCAT.DLL,$(WinSysPathSysFile),$(DLLSelfRegister),,5/31/98 12:00:00 AM,22288,4.71.1460.1
File3=@stdole2.tlb,$(WinSysPathSysFile),$(TLBRegister),,10/10/02 10:10:10 AM,17920,3.50.5014.0
File4=@asycfilt.dll,$(WinSysPathSysFile),,,10/10/02 10:10:10 AM,77824,3.50.5014.0
File5=@olepro32.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,10/10/02 10:10:10 AM,106496,5.0.5014.0
File6=@oleaut32.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,10/10/02 10:10:10 AM,569344,3.50.5016.0
File7=@msvbvm60.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,10/10/02 10:10:10 AM,1388544,6.0.92.37

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Win 98 "CAN'T CREATE OBJECT" Error 429
I have some clients running my application on Win98 who experience this error when starting up the program. I am using VB6, DAO and I am using Mirosoft Internet Controls in the app.

How do I avoid this error?

Thanks for any suggestions.

    David Abineri



Method "SaveAs" Or "Save" Of Object "Excel.Workbook" Does Not Work.
Hi people.
I did for a long time a program that uses excel automation, so that from a template will create a final file with some data pulled from the database (with ADO). At the end and when the Excel file is ready to be saved I got in a couple of computers some problems. In the whole LAN have XP, but in these 2 computers we have SP2. I have checked the rights and are OK (I have even tried to save the Workbook under the Temp folder and also the same problem).
Working with Office 2003 (SP1).
I have searched in internet about any bugs but I don´t find anything.
Any ideas.
Thanks for your time
Jaime

"Runtime Error-429 ActiveX Component Can't Create Object". For COM+ Component On Windows2003
"Runtime Error-429 ActiveX Component can't create Object". for COM+ component on Windows2003 ...?

Solution&gt; Error: """"&&H8007007E (-2147024770) The Specified Module Cannot Be Found"""
Hello

This is the error what i am getting after installing a package of one of my module on user testing machine.
The same module being working fine on others.


What can be the reason for this and what can be the probable solution for this?

Sandeep

Use COM Object From Excel VBA - Made In .NET "ActiveX Component Can't Create Object"
I have been unsuccessful at deploying a .NET project I created for Excel (VBA). I have this thread open in the VBA section. I figure I would try it in a higher traffic area of the site.

http://www.vbforums.com/showthread.p...hreadid=285832

Thanks

Use COM Object From Excel VBA - Made In .NET "ActiveX Component Can't Create Object"
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better.

I have created a simple COM DLL in .NET by using the COM class template and by setting output to a type library (DLL). All the object does is return a string value. At this point I have not checked the option to register for COM interop in Visual Studio.

So I go into Excel (where I want to use the object). Go to VB Editor and Tools -> References and to Add Reference. I browse until I find the in directory of the project. Select the .dll file outputted by the program. Then click open -> I get the message "Can't add reference to the specified file." So here is my first question: Why not?

So then I go to my project in Visual Studio. Highlight the project -> click properties ->go to Build -> and check "Register for COM interop" -> then I rebuild my solution. After this build there is another file in the in directory with the same name as the .dll but has the extension .tlb (Type Library).

So I go back into Excel. Go to VB Editor -> Tools -> References and to Add Reference. I browse until I find the in directory of the project. This time however I select the .tlb file outputted by the program. Then click open -> I don’t get an error message so this is good. So here is my second question: Why does the .tlb work and not the .dll at this point?

Now after this step. I create the object in VBA code. Compile and run the macro and sure enough it returns the string and puts in the right cell. Great! But wait. Now many more people need this object to work with Excel.

So I copy the Excel Workbook and everything in the in directory from my project to another person’s computer. Then I open the Excel workbook -> then to VB Editor -> References to double check the path to the .tlb file -> (then compile and save for peace of mind). But here is the big problem... when I run the macro on another person's computer I get the message "ActiveX component can't create object." And I get this at the line where I say: Set testObj = New Object.

My ideas... could it be that I am an Admin on my PC but not the other? If so, how do I get around this. Or is Visual Studio doing an extra step in the compile/build process that I’m not replicating on the other PC? Does it need to be an global assembly?

Also, .NET is installed on the other PC and I have tried to register the .DLL, but this is unsuccessful as well? I guess that is another question: why?

If someone could help me out here I would be very grateful. I have been trying to figure out a solution for a long time. I just don’t understand why everything works fine on my PC but won't run on another.

Thanks for being patient.
brazilnut

Vb6 Com+ Object Runs Once Then Errors With "activex Component Can't Create Object"
I have a vb6 com object that will run once successfully, then error with "activex component can't create object" on the call to the com object (see below, GetAppt.GetHRoomsAppointments). the com object (activex.dll) runs in com+ on a win2003 server. The project is set to run unattended, retain in memory, apartment threaded.

The com reads room numbers from oracle 9.2 client (via ado), then reads from outlook 2003 the rooms' appointments (cdo 1.21, outlook 11.0 object library references), and then writes the appointments back out to oracle (via ado). I have it running under com+ (in component services) using an administrator id (as identity) and activation as Server Application. I call the com object from a vb6 .exe.

If I run the code in vb6 debug mode, it works successfully on multiple runs. But once I compile into a .dll, add it to com+, and call from an .exe, it runs once. If I reboot the server, it will run successfully once. I was thinking I was leaving an object open but can not find it. I am doing close on recordsets, ado connections, and setting them to nothing.

How the code works is for each room, it will read from outlook, open an oracle recordset, add to the recordset, and then close the recordset.

Any ideas? I can send .dll code if need be. the .exe is below.
Is there a way to programmatically clean out the com object in the .exe besides setting it to Nothing?

Option Explicit
Sub Main()
Dim GetAppt As Object

Set GetAppt = New GetHRoomsAppts.clsGetHRoomsAppts
GetAppt.ProvID = "1234"
GetAppt.ProvName = "John Doe"
GetAppt.MailBoxServer = "xxx.abc.com"
GetAppt.eduDataBase = "ora.path.com"
GetAppt.apptFolderDir = "Public Folders/All Public Folders/Dept/SUN/Calendars/"
GetAppt.apptTableDir = "fileLoc.Appts"

GetAppt.GetHRoomsAppointments
Set GetAppt = Nothing

End Sub

"server Not Yet Been Opened" & "Object Variable Or With Block Variable Not Set" Error
I'm a new user of Crystal Report 8.5. I'm using VB6 and SQL Server 2000. I have designed a report at CR 8.5 and inserted it on VB 6, how will I connect?
I have tried a sample code below but I'm getting an "Object variable or with block variable not set" error. How do I solve this? Please Help. Thanks in advance Gurus

'General Declaration
Dim Report As New CrystalReport1
Dim crApp As New CRAXDRT.Application
Dim crReport As CRAXDRT.Report
Option Explicit

Private Sub Form_Load()
Dim crTable As cRAXDDRT.DatabaseTable
Set crReport = crApp.OpenReport("c:durden mmiclossratioreport.r pt")
crTable.SetLogOnInfo "servername", "dbasename", "userid", "password"
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub



And when I'm using this code, I'm getting a "Server has not yet been opened" error.



'General Declaration
Dim Report As New CrystalReport1
Dim crApp As New CRAXDRT.Application
Dim crReport As CRAXDRT.Report
Option Explicit

Private Sub Form_Load()
Dim crTable As cRAXDDRT.DatabaseTable
Set crReport = crApp.OpenReport("c:aris mmiclossratioreport.rpt ")
crReport.Database.Tables(1).SetLogOnInfo "mis002", "mqs", "aris", "110796"
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub



--

ADO Command Object Returns A "Method 'Execute' Of Object '_Connection' Failed" Error
Hi you all,
I have a VB6 app using an Access XP back end.
I Use a function which returns a Read Only, Disconnected ADO Recordset (used to populate lists, combos etc. using minimal resources).
I use it all the time without a hitch.
It started returning a "Method 'Execute' of object '_Connection' failed" error called with a SQL which works just fine when it's used as a query in the Access DB.
Why should the Execute method fail if the SQL works well in Access' Query design window?
Any help will be highly appreciated.
Thanx!
Guy

The function is:
Function GetDisconnectedRS(ByVal sSQL As String) As ADODB.Recordset
Dim adoRS As New ADODB.Recordset
Dim ucmdGetDisconnectedRS As ADODB.Command

Set ucmdGetDisconnectedRS = New ADODB.Command
With ucmdGetDisconnectedRS
.ActiveConnection = oConnect.ConnnectionObject
.CommandType = adCmdText
.CommandText = sSQL

Set adoRS = .Execute()

End With

Set adoRS.ActiveConnection = Nothing
Set GetDisconnectedRS = adoRS

SQL:
SELECT at.ActualTestID, at.PatientID, at.TestID, at.atDate, t.testDescription, p.patFirstName, p.patSurname
FROM (tblActualTests at INNER JOIN tblTests t ON at.TestID = t.TestID) INNER JOIN tblPatients p ON at.PatientID = p.PatientID WHERE at.atDate BETWEEN #02/08/2007# AND #02/08/2007# AND Not atDone
ORDER BY at.atDate DESC, at.TestID, p.patSurname

Just a note: The function works fine few code statements before it fails, with SQLs such as "SELECT DISTINCT patFirstName FROM tblPatients ORDER BY patFirstName".
I've tryed to run "SELECT * FROM tblActualTests" and it does work but hey, what's wrong with a few Joins?
And besides which the function didn't fail me in the past with much more complex SQLs.

Thanx,
Guy

Vbsendmail.dll Access 2003 "Active X Component Can't Create Object"
Hello.  I have been using vbsendmail.dll (I have the latest version of this file as well) in my Access 2000 VB Module for years and it works great.  I have a scheduled task that runs every morning and sends out about 20 different emails using the smtphost.  We have upgraded to Access 2003.  When the module starts to run the "Active X Component Can't Create Object" pops up.  I have gone thru all the help regarding this error.  When I try to use Regsrv32 there is an error: DllRegisterServer in C:windowssystemvbsendmail.dll failed.  Return Code is 0x80004005.  Any help on this would be greatly appreciated.  I just like the way this ran with no problem for so long and it would be ashame to have to go to something else but I am open to suggestions as well.  Thanks!

Pocket PC 2000 Emulator: ActiveX "Can't Create Object" Bug (Q260150)
I am unable to run ANY projects which use controls other than the default, basic ones such as textbox, commandbutton, etc. From what I gather, its a bug (260150) in which unused ActiveX components are "unregistered." Can anyone help?

WMI Failure - "ActiveX Component Can't Create Object"
i run this code because I need a list of printers from a windows 2000 AS.

But on two of my boxes I recieve "ActiveX component can't create object"

Can this be fixed?


Code:
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "
ootcimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_PrinterConfiguration")

Big Problem With "activeX Component Cant Create Object" #429
Hi Guys

Im acutaly working on a Mediacenter-Application. It always ran on all my computers, till i did include a new configfile-structure. On my work-pc everything works fine. But on my Notebook the Error 429 "ActiveX Component cant create object" appears. So i switched back to the old configfile structure. The Error seems to occur directly on startup of the software, so i can only guess where the problem is. The only OCX I use is mci32.ocx. For testing purposes is removed the activex components completely but the error still happens. Im going to drive crazy. Its a really BIG program. I work for it nearly a year. I have been working on this error for days, read every thread on this topic, but nothing could help me.
Here some Details...

I think the error must happen in one of these 2 Functions

Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer

Function Getini(ByVal INIFile As String, ByVal Section As String, ByVal Key As String)

Dim RetVal As String, Worked As Integer
RetVal = String$(255, 0)
Worked = GetPrivateProfileString(Section, Key, "", RetVal, Len(RetVal), INIFile)

If Worked = 0 Then
Getini = ""
Else
Getini = Left(RetVal, InStr(RetVal, Chr(0)) - 1)
End If

End Function


OR HERE:

Public Function GetWinDirectory() As String
Temp = Environ("windir")
If Right(Temp, 1) = "" Then Temp = Left(Temp, Len(Temp) - 1)
GetWinDirectory = Temp
End Function


This is the first part of the Form_Load sub. Here has to be the error!

Randomize Online = True
A = Right(Now, 8)
lastkey = Int(Right(A, 2)) + (Int(Mid(A, 4, 2)) * 60) + (Int(Left(A, 2)) * 60 * 60)
Themestatus = 1
Dim mixstat As Long
Mutestat = False
mixstat = OpenMixer(0)
Indizierung = False
tastdruck = False
ButtCH = True
WindowsDir = GetWinDirectory
IniPath = WindowsDir + "SARSMediacenter.ini"
'Lese Haupteinstellungen
progpath = Getini(IniPath, "Main", "Programmverzeichniss")

After the last line, no more code is executed and the error occurs.

Please Help me.

Thx Max

PS: I Am Working with VB5:-)

"ActiveX Component Can't Create Object"
I'm using AutoCAD with the software I'm writing in VB 6.0, and I need to use late binding because I don't know what version of Autocad will be on the user's computer. (When us reference the Autocad type library, you have to specify version). The trouble is I get the error "ActiveX component can't create object" Error #429 when I try to run the software on another computer with the same version of Autocad (2004) using late binding. The strange thing is, it works fine on this computer... I need this software to work problem-free when it is installed on another computer with Autocad.

Thanks, any help is welcome

DTS "ActiveX Component Can't Create Object"
Hello,

First time to include DTS Execution Module in a Visual Basic application. It runs well in my pc. However, I'm encountering errors such as "ActiveX component can't create object" in other pcs which has no SQL Server Installed. I've already checked dtspkg.dll, dtspump.dll and custtask.dll in the References yet without any luck, error still occurs.

Help!

If I Use "SaveSetting App.Title, "Settings", "Font", "001122"" - Save Date In The Registry, Where Ca
If i use "SaveSetting App.Title, "Settings", "Font", "001122"" - save date in the registry, where can i find the value saved in the registry? Thanks

How To Create A "Back" And "Forward" Button For The Web Browser Control
Does anyone know how to create a "Back" and "Forward" button for the web browser control? Thanks in advance.

Problem With "Object Reference Not Set To An Instance Of An Object" Error
Hi,

I ran into this “Object reference not set to an instance of an object" error in an application during debugging in VS 6.0

The app threw an exception in the frmProcessMonitor form at this line.

Set oStarDelete = CreateObject("StarReleaser.Release")

==> If oStarDelete.CanDeleteLoadFile(CDbl(sID)) = True Then



Is this because the “StarReleaser” DLL did not register properly?

The weird thing is that the production installed app works fine.

I tried to unregister and register the StarReleaser DLL and reboot but still have this problem when running the app in VS 6.0.


I will the project Reference next. Do you any idea/suggestion? Thanks

Prob With "Object Reference Not Set To An Instance Of An Object" Error
Hi all,
I have a vb.net program that sets up an excel sheet, and enters data from textboxes on a form into the first row of the excel sheet, which then can be exited disposing of resources. What i now need is to re-open the same excel sheet with the saved line of data, and enter new data into the next available free row of the excel sheet. I can open the sheet, but when I try to enter the data i get the "Object reference not set to an instance of an object" error. I have got very confused about why this is happening, and am hoping someone can tell me what changes i need to make to get this to work. I guess I need to refer to the object which is called using getobject, but I am not sure how.

Code:
checks for the excel file, uses getobject if the file exists
Sub OpenXLWorkBook(ByVal unidimensional_data)

Dim xlApp As Excel.Workbook
Dim xlWindow As Excel.Window

'Check to see if the file name passed in to
'the procedure is valid
If Dir("c:unidimensional_datadata.xls") = "" Then
'MsgBox("'" & "c:unidimensional_datadata.xls" & "' isn't a valid path!")
Call xlsetup()
'Exit Sub
Else
xlApp = GetObject("c:unidimensional_datadata.xls")

'Show the Excel Application Window
xlApp.Parent.Visible = True
xlApp.Windows(1).Visible = True
'Unhide each window in the WorkBook
'For Each xlWindow In xlApp.Windows
' xlWindow.Visible = True
' Next

'Prevent Excel from prompting to save changes
'to the workbook when the user exits
xlApp.Saved = True
End If

define the row and column of sheeet
Public row As Integer
Public column As Integer
look for a blank cell, add one to the row number until found then write value of text box to the cell
Private Sub tbox_subnum_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbox_subnum.TextChanged
row = 1
column = 1
Do Until (xlsheet.Cells(row + 1, column).value = "")
error appears to be on the 'value' in the line of code below
xlsheet.Cells(row, column).value = tbox_subnum.Text
Loop
'Call change(2, 1)
End Sub

Cheers in hope
Stu

"Run-time Error 424 - Object Required" Error When Upgrading A Activex Control
When I compile (upgrade) a activex control the program using it gives an error saying "Run-time error '424' - Object Required". If you delete the object from the vbp file and reopens the program and add the component again it'll work just fine.. But as soon as I try to upgrade this error will occur when trying to see the form of the new project using the upgraded activex control. The upgrade procedure seems to work fine though and the error occurs, as I said, only when I try to see the form of the project.

How Can I Create A Picture "object" ?
I made this bitmap and saved as a seperate file using a form and a picturebox control, but how am I supposed to do this on a console environment such as the Internet? Theoretically, I judge that I have to create a picture object by createobject statement and use its methods to form the image. Which object should that be ? Any other ideas ?

'Method "Range" Of Object "_Global" Failed.' ???
Hi!

I'm trying to create a VB app that interfaces with an Excel file. I can access the file okay. Part of the code is finding the next empty row in a range. I keep getting an error in the set range part of the code.


Code:
Dim rangeSearch As Range

xlSheet.Columns("A").Select
Set rangeSearch = Selection.Find(what:="*", After:=Range("A1"), lookin:=xlFormulas, _
lookat:=xlWhole, searchorder:=xlByRows, SearchDirection:=xlNext)
If Not rangeSearch Is Nothing Then
FindLastRow = rangeSearch.Row
MsgBox rangeSearch.Row
End If

The error is 'Method "Range" of object "_Global" failed.'

Anyone have any idea what this means?

Thanks!!!

Method "Range" Of Object "_Worksheet" Failed....???
What ever I do on this line:

Sheet1.Range(strColumn & 3).Value = strValue

I get an error:

Method "Range" of object "_Worksheet" failed.


I tried at least 10 different ways! What's wrong?? THIS line works fine:

LColorCells = "A" & Lrow & ":" & "J" & Lrow
    Sheet1.Range(LColorCells).Font.Color = vbwhite

So what's wrong with the above line??

I've tried for example:

Sheet1.Range("" &strColumn & str(3)).Value = strValue
Sheet1.Range("'" &strColumn & 3 &"'").Value = strValue

and more...

What's strange is that THIS WORKS:

Sheet1.Range("D" & 3).Value = strValue

But of course, he would only use Column "D" and I need to loop it cause strColumn is changing.

Can someone tell me what's wrong?
Thanks!




Edited by - Zvi on 11/8/2006 10:53:20 PM

Easy Way To Create "AA" "BA" "CA"... From A Number?
Hello All,

Looking for an easy way to convert the number 27 into column AA, 52 int "AZ" etc. (I think thats right! for 52 ...)

Or, is there anyway I just use (3,3) for "C3"?

Example:
appExcel.Range( ??? ).Value = SomeDataInArray

This has GOT to be easy, I just can't find reference, and I didn't want to hard code it if I don't have to.

Sprig

VB Error: 1004 Method Range Of Object "_Global" Failed
Hi All,
I am using MS Visual Basic for Applications (VBA) for Excel and I am very new to this programming. In fact, I merely copied a program from a book. I apologise for the length of it, but basically I am getting error "Run-time error '1004' Method "Range" of object "_Global" failed. It is happening at the following lines:

Range("Accuracy").Select
Range("Payoff").Select
Range("Money_Mgt_Approach").Select
etc etc

Would someone be kind enough to assist please? Any help in layman terms would be appreciated.

Cheers, Phil.

The program is as follows:

Code:
Sub Simulate_Risk_of_Ruin()

'
'Define variables
'
Const NoRecords = 10001
Dim TradeResult(NoRecords) As Long
Dim EquityCurve(NoRecords) As Long
Dim Accuracy As Variant
Dim PayOff_Ratio As Variant
Dim Money_Mgt_Approach As String
Dim Fixed_Percent_Risked As Variant
Dim Ruin_Point_DrawDown As Variant
Dim Account_Start As Variant
Dim Account_Balance As Variant
Dim Account_New_High As Variant
Dim Account_DrawDown As Variant
Dim Account_DrawDown_Percent As Variant
Dim Win_or_Loss As Variant
Dim Probability_Of_Ruin As Variant
Dim RowNumber As Variant
Dim Unit_Of_Money As Integer
Dim Fixed_Dollar_Risk As Variant
Dim Number_Of_Trades As Long
Dim Number_of_Losses_Before_Ruin As Long
Dim Number_of_Trades_Since_Account_High As Long
Dim i As Long
Dim j As Long
Dim x As Long

'
'Freeze Screen
'
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'
'Load Variables from Spreadsheet
'
'Load Accuracy Rate
Sheets("RiskOfRuin").Select
[b]Range("Accuracy").Select[/b]
Accuracy = Selection

'Load the Average Win to Average Loss Payoff Ration
[b]Range("Payoff").Select[/b]
PayOff_Ratio = Selection

'Load Money Management Approach
[b]Range("Money_Mgt_Approach").Select[/b]
If ActiveCell = 1 Then
Money_Mgt_Approach = "Fixed Percentage Risk Money Mgt"
Else
Money_Mgt_Approach = "Fixed Dollar Risk Money Mgt"
End If

'Load Starting Account Size
[b]Range("Start_Capital").Select[/b]
Account_Start = Selection

'Load Fixed Percentage Rate of account balance risked on each trade
[b]Range("FixedPercentage").Select[/b]
Fixed_Percent_Risked = Selection

'Load the Percentage Draw Down rate we define ruin as
Range("Ruin").Select
Ruin_Point_DrawDown = Selection

'Load the number of units of money we have in our account
Range("Unit_Of_Money").Select
Unit_Of_Money = Selection

'
'Clear the Arrays
'
For i = 1 To NoRecords
TradeResult(i) = Empty
EquityCurve(i) = 0
Next i
'
'Begin Simulating Probability of Ruin
'
Number_Of_Trades = 1
Account_Balance = Account_Start
Account_New_High = Account_Start
Account_DrawDown_Percent = 0
Number_of_Losses_Before_Ruin = 0
Fixed_Dollar_Risk = Account_Start / Unit_Of_Money

i = 1
j = 1
x = 0

Do Until Account_DrawDown_Percent >= Ruin_Point_DrawDown Or EquityCurve(i - 1) > 200000000 Or x >= 10000

'Check For New Equity High and reset number of losing trades to zero
If Account_Balance > Account_New_High Then
Account_New_High = Account_Balance
Number_of_Losses_Before_Ruin = 0
Number_of_Trades_Since_Account_High = 0
End If

'Generate random number to see whether a trade wins or loses
Win_or_Loss = Rnd

'Check for a Win
If Win_or_Loss >= (1 - Accuracy) Then
'We have a WIN!
'Calculate the profit
If Money_Mgt_Approach = "Fixed Percentage Risk Money Mgt" Then
TradeResult(j) = ((Fixed_Percent_Risked * Account_Balance) * PayOff_Ratio)
End If

If Money_Mgt_Approach = "Fixed Dollar Risk Money Mgt" Then
TradeResult(j) = Fixed_Dollar_Risk * PayOff_Ratio
End If

'Add to the equity curve
If i = 1 Then
EquityCurve(i) = Account_Start
i = i + 1
EquityCurve(i) = EquityCurve(i - 1) + TradeResult(j)
Else
EquityCurve(i) = EquityCurve(i - 1) + TradeResult(j)
End If

'We have a LOSS!
'Calculate the loss
If Money_Mgt_Approach = "Fixed Percentage Risk Money Mgt" Then
TradeResult(j) = -(Fixed_Percent_Risked * Account_Balance)
End If

If Money_Mgt_Approach = "Fixed Dollar Risk Money Mgt" Then
TradeResult(j) = -Fixed_Dollar_Risk
End If

'Add to the equity curve
If i = 1 Then
EquityCurve(i) = Account_Start
i = i + 1
EquityCurve(i) = EquityCurve(i - 1) + TradeResult(j)
Else
EquityCurve(i) = EquityCurve(i - 1) + TradeResult(j)
End If

'Add to our account balance
Account_Balance = Account_Balance + TradeResult(j)

'Calculate current drawdown and percentage drawdown
Account_DrawDown = Account_New_High - Account_Balance
Account_DrawDown_Percent = Account_DrawDown / Account_New_High

'Calculate the number of losses before ruin
Number_of_Losses_Before_Ruin = Number_of_Losses_Before_Ruin + 1

End If

'Calculate number of trades
Number_Of_Trades = Number_Of_Trades + 1
Number_of_Trades_Since_Account_High = Number_of_Trades_Since_Account_High + 1

'Increase counters
x = x + 1
j = j + 1
i = i + 1
Loop


'Calculate Probability of Ruin
Probability_Of_Ruin = Number_of_Losses_Before_Ruin / Number_of_Trades_Since_Account_High

'If the Equity Curve is above $200m or we have simulated 10,000 trades
'then we will assume ruin has been avoided.
If EquityCurve(i - 1) > 200000000 Or x >= 10000 Then
Probability_Of_Ruin = 0
End If

'Enter Probability of Ruin in Spreadsheet
Sheets("RiskOfRuin").Select
Range("Probability").Select
ActiveCell = Probability_Of_Ruin
Selection.Style = "Percent"

'
'Print Equity Curve
'
'Clear Previous Equity Curve
Columns("AA:AA").Select
Selection.Clear

'Print Equity Curve in Spreadsheet - Column AA
i = 1
Do Until i >= Number_Of_Trades + 1
Sheets(1).Cells(i, 27).Value = EquityCurve(i)
i = i + 1
Loop

'Change Chart Range
Range("AA1").Select
Selection.End(xlDown).Select
RowNumber = ActiveCell.Row

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Values = "=RiskOfRuin!R1C27:R" & RowNumber & "C27"
ActiveWindow.Visible = False
Windows("0_Risk_of_Ruin_Simulator.xls").Activate

'Move cursor to the Probability of Ruin calculation
Range("B22").Select

'
'Refresh Screen
'
Application.DisplayAlerts = True
Application.ScreenUpdating = True

'End of Simulator


End Sub

Error Message "Object Doesn't Support This Property Or Method"
When i trry to populate my listview i get a runtime error 438 saying "Object doesn't support this property or method" . I have 4 columns in my listview and this error occured for my last column. Can anyone help me with this?
This is the code i use to populate the listview.


VB Code:
Sql = SQLCommand("51", "", "")    Set OraDynaset = OraDatabase.CreateDynaset(Sql, 0&)    If OraDynaset.RecordCount <> 0 Then    OraDynaset.MoveFirst        Do While Not OraDynaset.EOF            Set itmx = ListView1.ListItems.Add(, , OraDynaset.Fields("Company_ID"))            itmx.SubItems(1) = OraDynaset.Fields("Dept_id")            itmx.SubItems(2) = OraDynaset.Fields("Customer_id")            itmx.sumitems(3) = OraDynaset.Fields("Customer_name")                    OraDynaset.MoveNext        Loop    End IfSet OraDynaset = Nothing

Error 2147467259 ("Method 'Execute' Of Object '_Connection' Failed")
Using Visual Basic 6.0, a connction object (cnAccess as ADODB.Connection), a recordset (rsmdl3 as ADODB.Recordset) and SQLCommand1(1 to 3) as strings. Using Microsoft ActiveX Data Objects 2.8 Library.

When I try to execute a long (>1200 characters) sql command (split into 3 string variables), I get the error mentioned in Subject.

Set rsMdl3 = cnAccess.Execute(SQLCommand1(1) & SQLCommand1(2) & SQLCommand1(3), , adCmdText)

When I paste the SQL command into Access as a query, the string is split into 2 (1st is 1023 characters long), but when the carrage return between the 2 sections is deleted, the query runs fine in Access.

Any ideas about how to populate the recordset with such a long SQL command?

ERROR: "Method 'OnAction' Of Object 'CommandBarButton' Failed"
Hi all!

Could I ask you for some assistance in trying to solve an issue that is truely puzzling me?

I've developed an Excel application that will add some custom menu entries whenever the code library is loaded...

This has been working great for all users (50 and more), but now this one UK colleague gets a "Method 'OnAction' of object 'CommandBarButton' Failed" error. And all was working great on het machine till a couple of days ago

Does anyone have a clue on what could be happening? I've tried reinstalling, but to no avail...

I'm adding the code for reference:


Code:
' add a submenu
Set cbSubMenu = Application.CommandBars.FindControl(, , "BfgSubMenu")

If cbSubMenu Is Nothing Then
Set cbSubMenu = cbMenu.Controls.Add(msoControlPopup, 1, , , True)
With cbSubMenu
.Caption = "&BFG..."
.Tag = "BfgSubMenu"
.BeginGroup = True
End With
End If

' add menuitem to submenu (or buttons to a commandbar)
With cbSubMenu.Controls.Add(msoControlButton, 1, , , True)
.Caption = "&New Manual Billing Request"
.OnAction = ThisWorkbook.Name & "!NewBillingRequest" ==> ERROR
.Tag = "NewMBR"
End With
Thank you in advance for your much appreciated help!
Cheers, Edgard

Error :"Method PrintOut Of Object Sheets Failed"
I am using VBA to convert .xls file to .ps file.
If the file name is Test123.xls,the code creates Test123.ps file.
I get following error message if the excel file name has comma in it (.eg. Tes,t123.xls)
"Method PrintOut of object Sheets failed"

So I am assuming that comma is invalid character for postscript file.
Am I correct?
Is there any way to know why code fails in PrintOut method?

Thanks in advance
Meghana

"Object Required" Error On Progress Bar Test *SOLVED*
I don't know anything about progress bar, and I found a code about testing the progress bar. The values for the max and min were set by the user by tying in text boxes. I wanted it to automatically perform the progress bar test, so I set the values myself. But I'm getting this "Object Required" error.


VB Code:
Dim intBarValue As Integer           prgTestBar.Min = CInt(900) 'In prethesis were the name of the txtBoxes.    prgTestBar.Max = CInt(0)' "          "    For intBarValue = prgTestBar.Min To prgTestBar.Max        prgTestBar.Value = intBarValue        DoEvents    Next         prgTestBar.Value = prgTestBar.MinEnd Sub


I don't know what's wrong, because I just simply replaced the value that is given by the user. But, like I said, I don't know anything about progress bars.

Did I give you guys enough info?

Thanks in advance.

"Object Variable Not Set" Error In Access With Linked Table
Hi;

Newbie here, still often baffled by the ins and outs of VBA.

I have an Access 97 database to record product sales and commission data. Often, when adding cureent sales data, we must add a new part number to the database. In our environment it works best to add the part number on the fly, and then go back to it at a later time to add certain other information to the Part Numbers table. The part number is the Primary Key of the table and must unique.

An acquaintance came up with this code to add a new part number to the table if the P/N is not found. This has been working fine for a long time. For various reasons I decided to place all the tables used for this other related databases in one central database, and link to the central database as needed. Now that the Part Numbers table is a linked table I get an error message saying, “Object Variable Or With Block Variable Not Set.” So apparently the new location is not properly defined. I’m guessing the problem is in the “Set RS” or “Set dB” commands, but my knowledge of these two commands in not enough to correct the problem. I’m sure this one is easy for someone out there.

Thanks

CODE
Private Sub Field80_NotInList(NewData As String, Response As Integer)
' Written
'This piece adds a new record directly to the Part number table.
'An error report will hit this new record for later input of info
'The reason is that it would be a pain logistically for the user to
'retrieve this specific information at run time.

Dim dB As Database
Dim RS As Recordset
Dim Msg As String
Dim CR As String: CR = Chr$(13)

'Exit Sub if the user cleared the selection.
If NewData = "" Then Exit Sub

'Ask if the user wants to add the new part number.
Msg = "Part Number " + NewData + " is not in the list." & CR & CR
Msg = Msg & "Do you want to add this number?"
If MsgBox(Msg, 32 + 4) = 7 Then '7=no
'If the user chooses no, instruct the user to try again
'MsgBox "Entered the do not add area"
Response = DATA_ERRCONTINUE
MsgBox "Please try again."
Else
'If the user selects yes, create a new record in the part number table
On Error Resume Next

'Open the Part Number Table
'MsgBox "Entered the add area"
Set dB = DBEngine.Workspaces(0).Databases(0)
Set RS = dB.OpenRecordset("Part Numbers", DB_OPEN_TABLE)


RS.AddNew
'msg = "Please enter the part number indicated on the input form"
RS("P/N") = NewData
RS.Update

'If an error occured while adding the record
If Err Then
'Instruct the user to try again
'MsgBox "into the error routine"
Response = DATA_ERRCONTINUE
Beep: MsgBox Error$, 48
MsgBox "Please Try Again"
Else
'If no error occured, add the element to the combo box list.
Response = DATA_ERRADDED
End If
End If

End Sub



Thanks, I'm looking forward to learning something new.

Error 3704 "operation Is Not Allowed When Object Is Closed"
I have an application that selects records from an access 97 database named tblStudent with sql (select) querry.The user then has to enter the rest of the fields and when he clicks save button,all the records are inserted using sql insert command into another table named studentInfo.I tried it the first time and it worked just fine but now its not working.What could be the problem with my code

Code:
Private Sub Command4_Click()
On Error Resume Next
Dim cn As Connection
Set cn = New Connection
Dim rs As New adodb.Recordset

If txtRegNo.Text = "" Then Exit Sub

sSQL = "SELECT Lastname,FirstName,MiddleName,Gender FROM tblStudent WHERE StudentID = '" & txtRegNo.Text & "'"

'SQL = " Select * from qrytblStudentInfo where StudentID = '" & txtRegNo.Text & "'"

Set rs = cn.Execute(SQL)

Set txtSurname.DataSource = rs
txtSurname.DataField = "LastName"
Set txtGender.DataSource = rs
txtGender.DataField = "Gender"
Set txtMiddleName.DataSource = rs
txtMiddleName.DataField = "MiddleName"
Set txtFirstname.DataSource = rs
txtFirstname.DataField = "FirstName"
Set txtContact.DataSource = rs
txtContact.DataField = "ParentsContactNumber"

Exit Sub
  
End Sub


Code:
Private Sub Command1_Click()
    Dim Special As Boolean
    Dim Allocate As String
    Dim rs as new adodb.recordset
    
    Dim cn As Connection

    sSQL = "insert into studentinfo (AdmissionNo,LastName,FirstName,MiddleName,sex) values('" & _
    txtRegNo & "','" & txtSurname & "','" & txtFirstname & "','" & txtMiddleName & "','" & txtGender & "')"
    
    Set RS = cn.Execute(SQL)
   
    Set txtRegNo.DataSource = rs
    txtRegNo.DataField = "AdmissionNo"
    Set txtSurname.DataSource = rs
    txtSurname.DataField = "LastName"
    Set txtFirstname.DataSource = rs
    txtFirstname.DataField = "FirstName"
    Set txtMiddleName.DataSource = rs
    txtMiddleName.DataField = "MiddleName"
    Set txtGender.DataSource = rs
    txtGender.DataField = "sex"
    
    MsgBox "Entry created"
       
        Exit Sub
    
ErrorHandler:
    MsgBox Err.Description
   
End Sub




Edited by - Geof on 7/22/2006 6:28:08 AM

Setting A Public Sub: "Object Doesn't Support This Property Or Method" Error *SOLVED*
I get this error when I tried to set a Public Sub: "Object doesn't support this property or method"

It was this:

VB Code:
Public Sub CenterForm(Frm)Frm.Move (Screen.Width - Frm.Width) / 2, (Screen.Height - Frm.Height) / 2End Sub


I only have two forms so I can just use it twice but I learned Public Subs and Modules today so I want to try it this way

I tried to put it at declaration part, a module, and I even changed Public to Private to nothing but they didn't seem to work.

It says that the error is on the whole line of

VB Code:
Frm.Move (Screen.Width - Frm.Width) / 2, (Screen.Height - Frm.Height) / 2


What is wrong with it? I tried changing Frm to Form to X. Didn't work also.

Any helps appreciated...

Edit:

It worked when I got rid of (Frm) and changed the Frm's with Me and worked on just one form cause I didn't put it in a module.

But when I did, it said, "Invalid use of Me Keyword"

On

VB Code:
Me.Move (Screen.Width - Me _ 'Error on this Me..Width) / 2, (Screen.Height - Me.Height) / 2

"object Does Not Support Property Of Method" Error
i am making a simple game right now i get a

"object does not support property of method" error.

why

I got the code for the transparency and image loading from a demo so i dont completly understand it. Run the attached files to see what the error and where it is in the code. The demo i got it from worked so i dont no why it does not for me.

"Public" Object Of UDT In Form Level Gives Error
Hello,

I have a 2 instances of my form. and If i am not wrong, I have all my form module variables declared as "Public" so that each instance can have their own variable values. (Private won't work right??)

Now, I have one Public UDT in my global module. but, why i can not delcare an object of this structure as Public in my form module.

So, How can i make my instances(of form) to use different instances of my UDT.

Example: This my form module

Code:
Public meID As Integer
Public mData As Message ' XX Gives Error

Private Sub Form_Load()

fr(0).meID = 1
fr(1).meID = 2

End Sub


This is my Globale module

Code:
Public Type Message
a As Long
b As Byte
c As Byte
d(7) As Byte
e As Long
End Type

Public fr(1) As Form1

"Operation Is Not Allowed When The Object Is Closed" ERROR !!!!
I've a Calculation command button and Update Command Button (Codes for two as follow), but I got error message (below) when clicking on Update command button and it seemed like my sql update table didn't work.

My purpose was that loading available unit in stock of selected product into Text2 box. After Quantity in Text2 box changed (by calculating command button), loading new value of Text2 back into WarehouseProductList in order that new value is loaded later (that is begining Text2 has quantity "20", after substracting "5". Number unit in stock later is loaded is "15")

ERROR MESSAGE

Run-time error '3704'
Operation is not allowed when the object is closed

CALCULATION CODE

Code:
Private Sub Cal_Click()

Dim a, b
a = Combo2.Text ' Warehouse name
b = ListProd.Text ' Product list from selected above warehouse

Set adoProd = New Recordset
sql = "Select * from WarehouseProd where WarehouseName = '" & a & "'" &_
" and ProdName = '" & b & "'"

adoProd.Open sql, db, adOpenStatic, adLockOptimistic
If Not adoProd.EOF And Not adoProd.BOF Then
Text1.Text = adoProd.Fields("ProdName")
Text2.Text = adoProd.Fields("Quantity")
End If

Dim c
c = InputBox("Enter Number of quantity", "Quantity", "")
If c > Val(Text2.Text) Then
MsgBox "Please input number greater than available unit in stock"
Cal.SetFocus
Exit Sub
End If

c = Val(c)
Text2.Text = Val(Text2.Text) - c
End Sub
-----------

UPDATE CODE

Code:
Private Sub Update_Click()
Dim a, b, c
Dim sql
a = combo2.Text ' list of warehouse name
b = lstProd.Text ' list of product when warehouse at combo2 box is selected
c = Val(Text2.Text) ' NEW value of Quantity box that change value from Calculation

Set adoProd = New Recordset
sql = "Update WarehouseProductList Set Quantity = '" & c & "'" & _
" where WarehouseName = '" & a & "'" & _
" and ProductName = '" & b & "'"

' This is where I get above error and I am not sure following coding is
' correct or not. I'd like to load new value of unit in stock back into
' WarehouseProductlist DBA in order that new value is shown instead of
' previous one. I've tried to delete line "adoProd.Update" but it gave
' wrong result. It changed value for both warehouse!!. For example:
' Warehouse ProductName Quantity Price
' A Orange Juice 20 1.5
' A Nonfat Milk 10 2.0
' B Orange Juice 30 1.5
' B Pork 10 3.0

' If there is a change at warehouse A with Orange Juice (used by 5), I'd
' like to ony warehouse A change Orange Juice quantity to 15 but my sql
' update reporting both Orange juice at Warehouse A and B changing.
' That is 15 for warehouse A and 25 for warehouse B????

adoProd.Open sql, db, adOpenStatic, adLockOptimistic
adoProd.Update
End Sub

Copyright © 2005-08 www.BigResource.com, All rights reserved