473,395 Members | 1,677 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,395 software developers and data experts.

Run-time error '438' (Help with VBA coding)

I have been getting this error:
"object doesn't support this object or method."

The debug is saying the problem is in the series of if statements based on which product I enter in the "drpProduct" control on the form. (Lines 26-48)

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnSave_Click()
  2.  
  3.     'Automatically sets the Location of the transaction to SSP. -AJB 4/13/11
  4.     Me.txtLocation = "SCP"
  5.  
  6.     'Makes sure a password is entered. -AJB 4/12/11
  7.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  8.         MsgBox "You must enter an authorization password.", vbOKOnly, "Invalid Entry"
  9.         Me.txtPassword.SetFocus
  10.     Exit Sub
  11.     End If
  12.  
  13.     'Redirects an incorrect password -JLJ 4/12/11
  14.     If Me.txtPassword <> Me.txtPasswordLookup Then
  15.         MsgBox "You have entered an invalid EID/password.", vbOKOnly, "Invalid Entry"
  16.         Me.txtPassword.SetFocus
  17.     Exit Sub
  18.     End If
  19.  
  20.     'If the transaction is Outbound, the stock adjustment number gets a negative sign added to the front of it. -AJB 4/12/11
  21.     If Me.drpIn_Out = "Outbound" Then
  22.         Me.txtStockAdjust = "-" & Me.txtStockAdjust
  23.     End If
  24.  
  25.     'Sets the stockID of the current transaction. -AJB 4/13/11
  26.     If Me.drpProduct = "Sleeved DVDs" Then
  27.         Me.txtStockNum = 1
  28.     End If
  29.  
  30.     If Me.drpProduct = "Cased DVDs" Then
  31.         Me.txtStockNum = 2
  32.     End If
  33.  
  34.     If Me.drpProduct = "6x9 Envelopes" Then
  35.         Me.txtStockNum = 3
  36.     End If
  37.  
  38.     If Me.drpProduct = "Booklets" Then
  39.         Me.txtStockNum = 4
  40.     End If
  41.  
  42.     If Me.drpProduct = "Letters" Then
  43.         Me.txtStockNum = 5
  44.     End If
  45.  
  46.     If Me.drpProduct = "Bibles" Then
  47.         Me.txtStockNum = 6
  48.     End If
  49.  
  50.     'Makes sure all of the controls are filled. -AJB 4/12/11
  51.     If Me.drpIn_Out = "" Or Me.txtLocation = "" Or Me.drpProduct = "" Or Me.txtStockAdjust = Null Or Me.txtPackerEID = "" Or Me.txtAuthEID = "" Or Me.txtTransDate = "" Or Me.txtStockNum = Null Then
  52.         MsgBox "Make sure all fields are filled.", vbOKOnly, "Incomplete Form"
  53.         Exit Sub
  54.     End If
  55.  
  56.     'Clears Password field. - AJB 4/15/11
  57.     Me.txtPassword = ""
  58.  
  59.     'Set Saved checkbox to true which will enable user to close the form. -AJB 4/13/11
  60.     Me.chkSaved = True
  61.  
  62.     'Everything was saved. -AJB 4/16/11
  63.     MsgBox "This inventory transaction was saved.", vbOKOnly, "Transaction Saved"
  64.  
  65. End Sub
  66.  
  67.  
Any kind of help would be greatly appreciated.
May 4 '11 #1
7 5603
NeoPa
32,556 Expert Mod 16PB
I'm confused as to why the line number is given as a range (26-48). In my experience only one line is highlighted when the error occurs (and that's the one we want to look at more closely).
May 4 '11 #2
For example, when I chose "Cased DVDs" line #31 is highlighted. Sorry for the confusion.
May 4 '11 #3
NeoPa
32,556 Expert Mod 16PB
Amy, you may want to consider a more succinct version of the code. This has many benefits, but one is that it's easier to ensure no errors get into the code. This code would replace your lines #25 to #48 :
Expand|Select|Wrap|Line Numbers
  1.     'Sets the stockID of the current transaction. -AJB 4/13/11
  2.     Select Case Me.drpProduct
  3.     Case "Sleeved DVDs" 
  4.         Me.txtStockNum = 1
  5.     Case "Cased DVDs" 
  6.         Me.txtStockNum = 2
  7.     Case "6x9 Envelopes" 
  8.         Me.txtStockNum = 3
  9.     Case "Booklets" 
  10.         Me.txtStockNum = 4
  11.     Case "Letters" 
  12.         Me.txtStockNum = 5
  13.     Case "Bibles" 
  14.         Me.txtStockNum = 6
  15.     End Select
Alternatively :
Expand|Select|Wrap|Line Numbers
  1.     'Sets the stockID of the current transaction. -AJB 4/13/11
  2.     With Me
  3.         .txtStockNum = Switch(.drpProduct="Sleeved DVDs",1, _
  4.                               .drpProduct="Cased DVDs",2, _
  5.                               .drpProduct="6x9 Envelopes",3, _
  6.                               .drpProduct="Booklets",4, _
  7.                               .drpProduct="Letters",5, _
  8.                               .drpProduct="Bibles",6)
  9.     End With
May 4 '11 #4
NeoPa
32,556 Expert Mod 16PB
Is there anything special about Me.txtStockNum? All else being standard, it's unusual for a TextBox control to struggle with a simple numeric assignment. I don't suppose any of your other controls have problems when any data is assigned to them from your code?
May 4 '11 #5
As far as I can tell, this is the only problem. I will implement the Case statements as you've suggested and let you know the results, and if any other controls are giving me problems.

Thank you!
May 4 '11 #6
Thank you, NeoPa, this was helpful, and the code is working now.
May 4 '11 #7
NeoPa
32,556 Expert Mod 16PB
I'm very pleased to hear it Amy, but if I'm honest, also a little surprised. What I suggested was a reworking (albeit a little more efficiently), but not a fix to any perceived problem.

At the end of the day though, working code is generally a good thing (even if the understanding of the actual problem eluded us all).
May 4 '11 #8

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

Similar topics

1
by: James | last post by:
Hi, I would like to run a custom script on a linux box via a button on a php page (php webpage hosted on the same linux box). Is this possible? If so , can you give me a pointer in the right...
5
by: hakim | last post by:
Hi, I need some information ? How I can run my project (Php) on CGI. Thanks.
2
by: Dica | last post by:
i'm just learning java now, so this might be obvious, but not to me. my app needs to do two things: (1) connect to and fetch a list of tasks for a user from a web service (2) connect to mapquest...
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...
12
by: Mactash | last post by:
Folks, I am trying just to run a simple asp commands in the Internet Explorer. ( I have windows XP) When I run this asp lines on ASP Matrix web server it is ok. But, when I run this on IIS...
4
by: SiuLoBow | last post by:
Hi, Is there anyway to detect the ActiveX control is able to run on the browser or not? After I installed the ActiveX control to my system, user sometimes switch the secruity setting to "not...
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:...
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. ...
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!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.