473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Run-time error help

Please can some one can help me resolve this bug?
Object variable or with block variable not set,

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private mVehicles   As CVehicles
  3. Private mstrKey     As String       'Holds form's key property
  4. Private mstrAction  As String       'Holds form's Action property
  5. Private mVehicle As New CVehicles
  6.  
  7.  
  8. Private Sub AssignProperties()
  9. 'assign properties from form
  10. mVehicle.InventoryID = Val(txtInventoryID.Text)
  11. mVehicle.Manufacturer = txtManufacturer.Text
  12. mVehicle.Modelname = txtModelName.Text
  13. mVehicle.Year = Val(txtYear.Text)
  14. mVehicle.VehicleID = Val(txtVehicleID.Text)
  15. mVehicle.CostValue = Val(txtCostValue.Text)
  16.  
  17. End Sub
  18.  
  19.  
  20. Private Sub cmdCancel_Click()
  21. 'Return to main form with no action
  22. FrmVehicle.Hide
  23.  
  24. End Sub
  25.  
  26. Private Sub cmdOk_Click()
  27. ' Choose Action depending upon Action setting
  28. Dim strVehicleInfo  As String
  29. Dim strkey  As String
  30.  
  31.  
  32. Select Case mstrAction
  33. Case "A"        'add Vehicle object
  34.     'Add to listBox and set ItemData to new object's key
  35.     strVehicleInfo = txtVehicleID.Text & "  " & txtModelName.Text & " " & txtYear.Text
  36.     With frmMain.lstVehicle
  37.             .AddItem strVehicleInfo
  38.             strkey = mVehicles.NextVehicleCode (the error is un this line)
  39.             .ItemData(.NewIndex) = Val(strkey)
  40.          End With
  41.     'Add Vehicle object to collection, setting the key
  42.     mVehicles.Add txtInventoryID.Text, txtManufacturer.Text, _
  43.     txtModelName.Text, txtYear.Text, txtVehicleID.Text, txtCostValue.Text, strkey
  44.  
  45. Case "R" 'Remove Vehicle object
  46.         With frmMain.lstVehicle
  47.                 .RemoveItem .ListIndex
  48.             End With
  49.             'Remove from Collection
  50.             mVehicles.Removal mstrKey
  51.         End Select
  52.  
  53.     'Return to main form
  54.     FrmVehicle.Hide
  55.  
  56. End Sub
  57.  
  58.  
  59.  
  60. Private Sub Form_Active()
  61. 'Set up the form for the selected action
  62. Select Case mstrAction
  63.     Case "A"
  64.     lblCommand.Caption = "Add New vehicle Info"
  65.     ClearTextBoxes
  66.     txtInventoryID.SetFocus
  67. Case "R"
  68.     lblCommand.Caption = "Remove this record?"
  69.     displayData
  70. Case "D"
  71.     lblCommand.Caption = "vehicle Display"
  72.     displayData
  73. End Select
  74. End Sub
  75. Private Sub Form_Load()
  76. 'Creat the vehicle collection object
  77. Me.Hide
  78. frmMain.Show vbModal
  79. Set mVehicles = New CVehicles
  80. End Sub
  81.  
  82. Private Sub form_Unload(Cancel As Integer)
  83. 'remove the Vehicle collection object from memory
  84. Set mVehicles = Nothing
  85. End Sub
  86.  
  87. Private Sub displayData()
  88. 'Transfer from the collection to field
  89.  
  90. With mVehicles.Item(mstrKey)
  91.     txtInventoryID.Text = .InventoryID
  92.     txtManufacturer.Text = .Manufacturer
  93.     txtModelName.Text = .Modelname
  94.     txtYear.Text = .Year
  95.     txtVehicleID.Text = .VehicleID
  96.     txtCostValue.Text = .CostValue
  97. End With
  98. End Sub
  99.  
  100. Private Sub ClearTextBoxes()
  101. 'Clear all of the text boxes
  102.  
  103.     txtInventoryID.Text = ""
  104.     txtManufacturer.Text = ""
  105.     txtModelName.Text = ""
  106.     txtYear.Text = ""
  107.     txtVehicleID.Text = ""
  108.     txtCostValue.Text = ""
  109.  
  110. End Sub
  111. Public Property Let Key(ByVal strkey As String)
  112. 'Assign the key property
  113.  
  114.         mstrKey = strkey
  115.  
  116.  
  117. End Property
  118. Public Property Let Action(ByVal strAction As String)
  119. 'Assign the Action property
  120.  
  121.         mstrAction = strAction
  122.  
  123. End Property
Aug 7 '07 #1
6 1441
to me this sounds like an ambiguous dim somewhere try checking out

http://support.microsoft.com/kb/316478

maybe it will help
Aug 7 '07 #2
to me this sounds like an ambiguous dim somewhere try checking out

http://support.microsoft.com/kb/316478

maybe it will help
I try that link but unfortunatly I couldn't solve the problem
Aug 7 '07 #3
fplesco
82
Please can some one can help me resolve this bug?
Object variable or with block variable not set,...
Hi -

I've noticed in your declaration below

Private mVehicles As CVehicles
Private mVehicle As New CVehicles

You must be using mVehicle because its the one instantiated (see New keyword).

So put,
strkey = mVehicle.NextVehicleCode (the error is un this line)
instead..

If it doesnt work, maybe you can check the .NextVehicleCode method because I couldn't see it in properties below.

Expand|Select|Wrap|Line Numbers
  1. Private Sub AssignProperties()
  2. 'assign properties from form
  3. mVehicle.InventoryID = Val(txtInventoryID.Text)
  4. mVehicle.Manufacturer = txtManufacturer.Text
  5. mVehicle.Modelname = txtModelName.Text
  6. mVehicle.Year = Val(txtYear.Text)
  7. mVehicle.VehicleID = Val(txtVehicleID.Text)
  8. mVehicle.CostValue = Val(txtCostValue.Text)
Aug 8 '07 #4
Killer42
8,435 Expert 8TB
Please can some one can help me resolve this bug?
...
I don't think you pointed out which line produces the error.

P.S. Oh my gawd, it's the Executioner! :)
Aug 8 '07 #5
fplesco
82
I don't think you pointed out which line produces the error.

P.S. Oh my gawd, it's the Executioner! :)
It's in BOLD font, alright? mVehicle and mVehicles' difference isn't really noticeable.
Aug 10 '07 #6
Killer42
8,435 Expert 8TB
It's in BOLD font, alright? mVehicle and mVehicles' difference isn't really noticeable.
Yes, I know you pointed out that line as the error. I was hoping to get some input form the OP on what they experienced. Obviously, chances are good that it's the same. But it doesn't hurt to confirm these things.
Aug 10 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
2
by: Jenna Olson | last post by:
Hi all- I've never seen this particular issue addressed, but was wondering if there's anything to support one way or another. Say I have a class: class ManipulateData { public:...
15
by: mg | last post by:
How can I run an .exe using C# from within the code behind of a WebForm app?
6
by: billr | last post by:
I have developed a small API for taking care of a lot of boiler plate stuff in a multi formed windows application, for example setting up a messaging thread framework. New Forms, in the...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
7
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.