473,799 Members | 3,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Runtime error 424

towsie
28 New Member
Hi,

I am having a problem with code below, I am getting a runtime error 424: Object Required.

The section of code in bold is where the error occurs.

Any help would be greatly appreciated.



'Allows user to upload Enterprise SGD Sales from Excel Spreadsheet
Private Sub butEnterpriseSG DUpload_Click()

Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim strWorkbook As String
Dim rstCounter As Recordset
Dim rstCheck As Recordset
Dim intCounter As Long

DoCmd.SetWarnin gs (False)

Set db = CurrentDb

'Check to see if data already exists in t_sales table for current accounting month
'Set rstCheck = db.OpenRecordse t("SELECT [acct_month] FROM [t_sales] WHERE [acct_month] = " & Forms!frmUpload Sales.txtAccMon th & " and [upload_flag] ='U';")
'If rstCheck.Record Count > 0 Then
' If MsgBox("This summary has already been run for the current period ( acct_month " & Forms!frmUpload Sales.txtAccMon th & "). " & Chr(13) & _
' " Do you want to overwrite the data for this period?", vbOKCancel, "Warning") = vbOK Then
' strSQL = "delete from t_sales where acct_month = " & Forms!frmUpload Sales.txtAccMon th & " and upload_flag='U' ;"
' DoCmd.RunSQL (strSQL)
' Else
' Exit Sub
' End If
'End If

'Prompt for Enterprise SGD xls
strWorkbook = strGetOpenFileN ame("Excel Files (*.xls)" & Chr(0) & "*.xls" & Chr(0), "H:\", , "Select Enterprise SGD workbook")

If strWorkbook = "False" Then
Exit Sub
End If

DoCmd.Hourglass (True)
Set rstCounter = db.OpenRecordse t("SELECT Max(t_sales.sal e_number) AS Max FROM t_sales;")

If IsNull(rstCount er(0)) Then
intCounter = 1
Else
intCounter = rstCounter(0) + 1
End If

'Get Enterprise SGD sales from Excel spreadsheet and set upload flag = U

Set xl = db.CreateTableD ef("EnterpriseS GD")
xl.Connect = "Excel 5.0;HDR=NO;IMEX =1;DATABASE=" & strWorkbook
xl.SourceTableN ame = "SGD$"
db.TableDefs.Ap pend xl

Set rs = db.OpenRecordse t("Select t_sales_templat e.product, t_sales_templat e.category, t_sales_templat e.customer, t_sales_templat e.origin_of_sal e, t_sales_templat e.load_point, t_sales_templat e.vessel, t_sales_templat e.credit_period , t_sales_templat e.sales_terms, t_sales_templat e.shipping_term s, t_sales_templat e.contract_numb er, t_sales_templat e.vat, t_sales_templat e.invoice_curre ncy, t_sales_templat e.autolift, t_sales_templat e.value_only, t_sales_templat e.export, t_sales_templat e.invoice_unit, t_sales_templat e.tax_unit, t_sales_templat e.ledger_unit, t_sales_templat e.contract_date " & _
"From t_sales_templat e;")


If rs.RecordCount = 0 Then
Else
rs.MoveLast
rs.MoveFirst
Do While Not rs.EOF
strSQL = "Insert into t_sales (product, category, customer, origin_of_sale, load_point, vessel, credit_period, sales_terms, shipping_terms, contract_no, vat, invoice_currenc y, autolift, value_only, export_ind, invoice_unit, tax_unit, ledger_unit, contract_date, sale_number)" & _
" values(" & t_sales_templat e.Product & "," & t_sales_templat e.Category & "," & t_sales_templat e.Customer & "," & t_sales_templat e.Origin_of_sal e & "," & t_sales_templat e.Load_point & "," & t_sales_templat e.Vessel & "," & t_sales_templat e.Credit_period & "," & t_sales_templat e.Sales_terms & "," & t_sales_templat e.Shipping_term s & "," & t_sales_templat e.Contract_Numb er & "," & t_sales_templat e.VAT & "," & t_sales_templat e.Invoice_curre ncy & "," & t_sales_templat e.Autolift & "," & t_sales_templat e.VALUE_ONLY & "," & t_sales_templat e.Export & "," & t_sales_templat e.invoice_unit & "," & t_sales_templat e.Tax_unit & "," & t_sales_templat e.Ledger_unit & "," & t_sales_templat e.Contract_date & "," & intCounter & ")" & _
" where( t_sales_templat e.Template_Name = ' Methane - SGD Portfolio - Enterprise Bittern ')"
DoCmd.RunSQL (strSQL)
DoCmd.RunSQL ("update t_sales set upload_flag= 'U'")
intCounter = intCounter + 1
rs.MoveNext
Loop
End If

End Sub
Sep 25 '07 #1
15 3903
fplesco
82 New Member
Hi,

I am having a problem with code below, I am getting a runtime error 424: Object Required.

The section of code in bold is where the error occurs.

Any help would be greatly appreciated.



'Allows user to upload Enterprise SGD Sales from Excel Spreadsheet
Private Sub butEnterpriseSG DUpload_Click()
Hi Towsie -

As I see your code, it seemed to me that these values you want to insert in T_Sales table is fetched coming from another table and is available in RS recordset.

If that's really the case.

add rs! in the field, see below:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "Insert into t_sales (product, category, customer, origin_of_sale, load_point, vessel, credit_period, sales_terms, shipping_terms, contract_no, vat, invoice_currency, autolift, value_only, export_ind, invoice_unit, tax_unit, ledger_unit, contract_date, sale_number)" & _
  2. " values(" & rs!t_sales_template.Product & "," & rs!t_sales_template.Category & "," & rs!t_sales_template.Customer & "," & rs!t_sales_template.Origin_of_sale & "," & rs!t_sales_template.Load_point & "," & rs!t_sales_template.Vessel & "," & rs!t_sales_template.Credit_period & "," & rs!t_sales_template.Sales_terms & "," & rs!t_sales_template.Shipping_terms & "," & rs!t_sales_template.Contract_Number & "," & rs!t_sales_template.VAT & "," & rs!t_sales_template.Invoice_currency & "," & rs!t_sales_template.Autolift & "," & rs!t_sales_template.VALUE_ONLY & "," & rs!t_sales_template.Export & "," & rs!t_sales_template.invoice_unit & "," & rs!t_sales_template.Tax_unit & "," & rs!t_sales_template.Ledger_unit & "," & rs!t_sales_template.Contract_date & "," & intCounter & ")" & _
  3. " where( t_sales_template.Template_Name = ' Methane - SGD Portfolio - Enterprise Bittern ')" 
  4.  
  5.  
Sep 25 '07 #2
towsie
28 New Member
Hi,

I have changed my code to



Set rs = db.OpenRecordse t("Select product, category, customer, origin_of_sale as origin, load_point as lp, vessel, credit_period as credit, sales_terms, shipping_terms, contract_number as contract_no, vat, invoice_currenc y as curr, autolift, value_only, export, invoice_unit, tax_unit, ledger_unit, contract_date " & _
"From t_sales_templat e;")


If rs.RecordCount = 0 Then
Else
rs.MoveLast
rs.MoveFirst
Do While Not rs.EOF
strSQL = "Insert into t_sales (product, category, customer, origin_of_sale, load_point, vessel, credit_period, sales_terms, shipping_terms, contract_no, vat, invoice_currenc y, autolift, value_only, export_ind, invoice_unit, tax_unit, ledger_unit, contract_date, sale_number)" & _
" values(" & rs("product") & "," & rs("category") & "," & rs("customer") & "," & rs("origin") & "," & rs("lp") & "," & rs("vessel") & "," & rs("credit") & "," & rs("sales_terms ") & "," & rs("shipping_te rms") & "," & rs("contract_no ") & "," & rs("vat") & "," & rs("curr") & "," & rs("autolift") & "," & rs("value_only" ) & "," & rs("export") & "," & rs("invoice_uni t") & "," & rs("tax_unit") & "," & rs("ledger_unit ") & "," & rs("contract_da te") & "," & intCounter & ")" & _
" where( t_sales_templat e.Template_Name = ' Methane - SGD Portfolio - Enterprise Bittern ')"
DoCmd.RunSQL (strSQL)
DoCmd.RunSQL ("update t_sales set upload_flag= 'U'")
intCounter = intCounter + 1
rs.MoveNext
Loop
End If

End Sub

I now error an error

runtime error 3075: Syntax error (missing operator) in query expression 'CRUDE OIL'

I have made the line that errors bold.

Thanks

Towsie
Sep 26 '07 #3
towsie
28 New Member
I have now solved this error, but now I am getting runtime error 3137: Missing semicolon (;) at end of the SQL statement.

Expand|Select|Wrap|Line Numbers
  1. If rs.RecordCount = 0 Then
  2. Else
  3.     rs.MoveLast
  4.     rs.MoveFirst
  5.     Do While Not rs.EOF
  6.             strSQL = "Insert into t_sales (product, category, customer, origin_of_sale, load_point, vessel, credit_period, sales_terms, shipping_terms, contract_no, vat, invoice_currency, autolift, value_only, export_ind, invoice_unit, tax_unit, ledger_unit, contract_date, sale_number)" & _
  7.             " values('" & rs("product") & "','" & rs("category") & "','" & rs("customer") & "','" & rs("origin") & "','" & rs("lp") & "','" & rs("vessel") & "','" & rs("credit") & "','" & rs("sales_terms") & "','" & rs("shipping_terms") & "','" & rs("contract_no") & "','" & rs("vat") & "','" & rs("curr") & "','" & rs("autolift") & "','" & rs("value_only") & "','" & rs("export") & "','" & rs("invoice_unit") & "','" & rs("tax_unit") & "','" & rs("ledger_unit") & "','" & rs("contract_date") & "'," & intCounter & ")" & _
  8.             " where(template_name  = ' Methane - SGD Portfolio - Enterprise Bittern ')"
  9.             DoCmd.RunSQL (strSQL)
  10.             DoCmd.RunSQL ("update t_sales set upload_flag = 'U'")
  11.             intCounter = intCounter + 1
  12.     rs.MoveNext
  13.     Loop
  14. End If
Sep 26 '07 #4
Killer42
8,435 Recognized Expert Expert
I have now solved this error, but now I am getting runtime error 3137: Missing semicolon (;) at end of the SQL statement.
So, put a semicolon on the end of your SQL statement - problem solved.
Sep 26 '07 #5
towsie
28 New Member
I have already tried that but there was no success.
Sep 27 '07 #6
QVeen72
1,445 Recognized Expert Top Contributor
I have now solved this error, but now I am getting runtime error 3137: Missing semicolon (;) ...
Hi,
OK, just a few points I noted:
* Why not Open 2 Recordsets and use "AddNew" method, that way you can trap errors better.
* contract_date.. . wrap with "#" not single quote.
* All the fields you have wrapped with single quote, Numeric/Currency values should be without quotes.
* What if any field value of the "rs" object is "Null"?

Regards
Veena
Sep 27 '07 #7
towsie
28 New Member
Hi,

None of fields are null, I have removed the quotes from the numeric fields and and added the # for contract_date but I receive the same error.
Sep 27 '07 #8
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Why do you need Where condition here?
where(template_ name = ' Methane - SGD Portfolio - Enterprise Bittern ')"

What is template_name ?
Is it a field name (from rs) or Control name in the form?


Regards
Veena
Sep 27 '07 #9
towsie
28 New Member
Hi,

The where condition is used to make sure that the correct data is input for each record in the recordset. I am just using that template at the moment to make sure that the correct data is being input into the table.
Sep 27 '07 #10

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

Similar topics

5
15949
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived from an Abstract class, I do not believe that this class object is causing me my problem. Below is that message I have posted before to other groups. Question:
5
15124
by: Nathan Bloom | last post by:
Hi, I have a secured database that runs fine on the computer the database is installed on. I have several workstations with access runtime installed that also need access to the database. Access runtime runs fine when accessing an unsecured version of the database. However once the database was secured it generates a runtime error after asking for the user and password and won't open. The shortcut to the secured database is: "path...
2
3579
by: Paul | last post by:
I'm hoping someone can help me with the problem. I have a database where the default value for a date field in a table is =date() This works perfectly in my table and on my form. But when I complile the DB into a 97 Runtime, the date field displays and #error? in the runtime. But if I open the runtime db on a system with Access 97, there is no error. I have tried the runtime on mulitple systems (that dont have Access installed) and...
12
3476
by: Markus Ewald | last post by:
I'm just experimenting around with the VisualC++ 2005 Express Edition Beta and found some strange behavior for which I can't seem to find a workaround. What I've done is set up two static library projects for Lua 5.0.2 and LuaBind beta-6, compiling both with no CLR support and configured to use the Multithreaded DLL runtime. Then I created a new console application which makes use of these two static libraries (of course, also set to MT...
0
755
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. The same code works fine in a standalone app. I have inspected System.Runtime.Remoting.dll with ildasm, and I can see the ....Channels.Http namespace there. I verified that the virtual directory is configured to use v2.0.50727 (the error message...
0
3244
by: zfraile | last post by:
I'm getting this error from the JIT compiler at runtime, but only on my boss' machine, not my development machine. I believe the error is generated from a call to an Excel object, but I can't tell why or what specific action on the object is causing it. We both are running version 2.0 of the .net framework with Office 2003 installed, though I am running XP and she has Win2000. Also, I do not get this error when running another sub in...
0
2166
by: Yelena Varshal via AccessMonster.com | last post by:
Hello We have a shortcut for our MS ACCESS application that uses a /Runtime switch because we may have some users that use Runtime. The application worked fine in Access 2000 and was tested with 2003 in the spring. Now that we started to use it with MS ACCESS 2003 (Full version) we are getting the error on the last form close when exiting the application. We don't have this error if deleting /Runtime switch from the shortcut.. The error...
7
8456
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then this installer will install them. But what about the situation where VC runtime has already been installed? In fact it's been installed twice. Although the project was built on a Windows XP system with Visual Studio 2005 SP1 and the results were...
3
5192
by: Jim Armstrong | last post by:
Hello all - This is driving me crazy. I have a table called tblClients - very simple, has the following fields: taxID (PK) ClientName SalesName The main form of my application allows a user to select a client and
1
4088
by: BL3WC | last post by:
Hi, I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the Access 2007 runtime on a test machine and place the MDE in the Desktop for user's initial testing. I did not create a trust area for this MDE in the test machine as well as in my development machine. When I tested the MDE using /runtime switch in my...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10214
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10023
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7561
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2935
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.