473,624 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem using UpdateBatch in ADO with INNER JOIN...

patjones
931 Recognized Expert Contributor
Hi:

I am attempting to pull a backend table into a local recordset, make some changes to it, and commit the changes back to the table. I'm using an ADO recordset in Access 2007. The backend resides on a network drive while the front end is on my C: drive. My code is as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. Dim rstBalances As New ADODB.Recordset
  4. Dim strSQL As String
  5.  
  6. strSQL = "SELECT fldDateEffective, fldCurrentAL, fldCurrentSick, fldCurrentCT, fldHoursPerDay , fldRDO1 , fldRDO2 FROM tblLeaveBalances INNER JOIN (tblEmployee INNER JOIN tblTitles ON tblEmployee.fldTitleCode = tblTitles.fldTitleCode) ON tblEmployee.fldERN = tblLeaveBalances.fldERN"
  7.  
  8. With rstBalances
  9.     .CursorLocation = adUseClient
  10.     .LockType = adLockBatchOptimistic
  11.  
  12.     .Open strSQL, conn
  13.  
  14.     Do While Not .EOF
  15.  
  16.         If .Fields.Item(1) > 300 Then
  17.  
  18.             .Fields.Item(1) = .Fields.Item(1) - (GetNumOfWorkdays(.Fields.Item(0), Date, .Fields.Item(5), .Fields.Item(6)) - 1) * .Fields.Item(4)
  19.             .Fields.Item(0) = Format(Date, "mm/dd/yy")
  20.  
  21.         End If
  22.  
  23.         .Update
  24.         .MoveNext
  25.  
  26.     Loop
  27.  
  28.     .UpdateBatch
  29.  
  30.     .Close
  31.  
  32. End With
  33.  
  34. Set rstBalances = Nothing
  35.  
It pulls the data and loops through the records just fine. However, I get a "6 - Overflow" error on the .UpdateBatch.

Now, when I try this with a simpler recordset that does not involve any JOINS, it works fine. Unfortunately, in order to do the update, I need information from two other tables - although I'm only updating information in one table. From what I've been able to find out, it seems like there might be a problem trying to do an .UpdateBatch on an INNER JOIN recordset?

I'm aware that this is not the best performing method for doing this. I just can't think of another way to accomplish my goal at this point. Thanks for any and all help!

Pat
Jul 17 '08 #1
1 3586
patjones
931 Recognized Expert Contributor
Hi:

Figured the problem out. The fields that I'm using to put together the ON clauses for my INNER JOINS...were not listed in the SELECT clause. The following appended SQL string works, and causes the code to function properly:

Expand|Select|Wrap|Line Numbers
  1.  
  2. strSQL = "SELECT tblLeaveBalances.fldDateEffective, tblLeaveBalances.fldCurrentAL, tblLeaveBalances.fldCurrentSick, tblLeaveBalances.fldCurrentCT, tblTitles.fldHoursPerDay , tblEmployee.fldRDO1 , tblEmployee.fldRDO2, tblEmployee.fldERN, tblEmployee.fldTitleCode, tblTitles.fldTitleCode, tblLeaveBalances.fldERN FROM tblLeaveBalances INNER JOIN (tblEmployee INNER JOIN tblTitles ON tblEmployee.fldTitleCode = tblTitles.fldTitleCode) ON tblEmployee.fldERN = tblLeaveBalances.fldERN"
  3.  
  4.  
Pat
Jul 17 '08 #2

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

Similar topics

2
1945
by: Bruce Duncan | last post by:
I'm a bit new to MySQL (know MS SQL well...and that may be the problem...getting the syntax confused) and I'm having a join problem...can anyone offer some help? Here's my problem: I have table1 that needs to "left" join to table1A, table1B, and table1C which is corrently done with the following: select table1.x, table1a.y, table1b.z, table1c.q from table1 left join table1a on table1.ID = table1a.ID left join table1b on table1.ID =...
1
1403
by: Keith | last post by:
I have created a view to test some of the data in my database. I am relatively new to SQL so may have caused this problem by doing something wrong. I have a table called SYS_Individual which contains records on individuals. A number of the fields in this take a numeric entry which corresponds to an entry in another table (used to populate drop down menus in the application being developed). The tables which are used for the dropdowns...
2
908
by: Keith | last post by:
I am having a problem creating a many-to-many-to-many type relationship. It works fine, but when I create a view to query it and test it, it does not generate the results I expected. Below if the DDL for the tables and the SQL for the view.
8
19581
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
1
4167
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a couple of tables in my database using INNER JOINS and the WHERE clause to specify the required constraints. However, I also want to read two fields from a *single* record from a table called 'Locations' and then apply one of these field's values...
1
6258
by: lovkeshanand | last post by:
Dear All, I am using the oracle transparent gateway connectivity with sql server using tg4msql,as far as settings are concerned those were set and Connectivity is working Fine, and getting the response from that server. here is description what I done as:-There is a View on Sqlserver which is Join of 6 tables and have
1
3104
by: imranpariyani | last post by:
Hi i have a severe performance problem with one of my views which has 6 to 8 joins .. any help will be appreciated.. the view is: CREATE OR REPLACE VIEW thsn.trade_view AS SELECT tra.tra_id, tra.per_id, tra.fir_id, tra.tra_dcn, tra.tra_startdate::date AS tra_startdate, tra.tra_enddate::date AS tra_enddate, tra.tra_highprice, tra.tra_lowprice, tra.tra_shares, tra.tra_marketvalue, tra.tra_commonsharesheld, tra.tra_directsharesheld,...
9
5749
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just call it Express for simplicity). I have, to try to simplify things, put the exact same DB on two systems, one running MSDE and one running Express. Both have 2 Ghz processors (one Intel, one AMD), both have a decent amount of RAM (Intel system...
10
3720
by: MLH | last post by:
Gentlemen: I am having one heck of a time taking a DAO walk through the records in an SQL dynaset. I'm trying to walk a set of records returned by a UNION query. I'm attempting to filter the records to those related to vehicle #60 ( = 60 ). If I explicitly specify 60 in the SQL ==everything works fine. Take a look: 100 PString = "SELECT & " & Chr$(&H22) & Space(1) & Chr$(&H22) & " & AS Recipient " 120 PString = PString & "FROM...
0
8236
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
8173
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,...
0
8621
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8475
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...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
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
4079
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
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
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.