473,473 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

access 97: insert into and multiple records of the same loan problems

i am running into problems with is the recordset. i have exactly 104
records. when i tested the code, the end result was multiple records
for the same loan(ET LN Shortname). where did i go wrong? so i tried
a couple of different do... loop statements and ended up getting the
same results, that is having multiple records of the same loan(ET LN
Shortname). so if anyone has any suggestions, it would be appreciated
:) thanks in advance and all who gave me advice. jung

Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("ETracking")

''If rst.RecordCount > 0 Then
''Do While Not rst.EOF
Do Until rst.EOF
db.Execute " INSERT INTO ETracking([ET Number], [ET LN
Shortname], [ET Amount], [ET EC Code])" _
& " SELECT(SELECT(Max([ET Number])+1) FROM ETracking),
tblImportET.[ET LN Shortname], tblImportET.[ET Amount],
tblImportET.[ET EC Code] FROM [tblImportET]; "
rst.MoveNext
Loop

Set rst = Nothing
Set tdf = Nothing
Set db = Nothing
'End If
Nov 12 '05 #1
2 4162
hello -
here is an updated version. for some reason the [ET Amount] is a
string data type instead of currency when looking in the debug window.
i checked out both tables "Etracking" and "tblImportET" to make sure
the the field [ET Amount] is data type currency and it is . could it
be something with my insert into value statement that makes the [ET
Amount] a string?

Set db = DBEngine(0)(0)
Set rstET = db.OpenRecordset("tblImportET")
Set rst2 = db.OpenRecordset("Etracking")

rstET.MoveFirst
Do Until rstET.EOF

y = rstET![ET LN Shortname].Value
z = rstET![ET Amount].Value
x = "INSERT INTO ETracking([ET Number], [ET LN Shortname], [ET
Amount]) " _
& "VALUES (200000, '" & rstET![ET LN Shortname].Value & "'
, " & rstET![ET Amount].Value & ");"

'DoCmd.SetWarnings False
DoCmd.RunSQL (x)
'DoCmd.SetWarnings True
rstET.MoveNext
Loop
rstET.Close

'End With

Set rstET = Nothing
Set tdf = Nothing
Set db = Nothing
Nov 12 '05 #2
hello -
here is an updated version. for some reason the [ET Amount] is a string
data type instead of currency when looking in the debug window. i
checked out both tables "Etracking" and "tblImportET" to make sure the
the field [ET Amount] is data type currency and it is . could it be
something with my insert into statement that makes the [ET Amount] a
string?

Set db = DBEngine(0)(0)
Set rstET = db.OpenRecordset("tblImportET")
Set rst2 = db.OpenRecordset("Etracking")

rstET.MoveFirst
Do Until rstET.EOF

y = rstET![ET LN Shortname].Value
z = rstET![ET Amount].Value
x = "INSERT INTO ETracking([ET Number], [ET LN Shortname], [ET
Amount]) " _
& "VALUES (200000, '" & rstET![ET LN Shortname].Value & "' ,
" & rstET![ET Amount].Value & ");"

'DoCmd.SetWarnings False
DoCmd.RunSQL (x)
'DoCmd.SetWarnings True
rstET.MoveNext
Loop
rstET.Close

'End With

Set rstET = Nothing
Set tdf = Nothing
Set db = Nothing
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jh8735 | last post by:
I use Access to run reports from various pieces of financial data. The one query that I have been unable to produce, but need is the following: A query that yields all accounts from a person...
4
by: JMCN | last post by:
i received a runtime error message 3346 when i ran the insert into select code. i have check to see if the query values and destination fields are the same and it appears so. atlas, i have no idea...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
4
by: JMCN | last post by:
hello i am not getting the correct percentage results from the following code. the "prelimpercent" variable = 0? why would that be the case when i try to divide numrecs by numrecs2? any advise...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
9
by: dan | last post by:
within a loop i am building a sql insert statement to run against my (programatically created) mdb. it works but it seems unreasonably SLOW! Sorry, dont have the code here but the jist is very...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
6
by: jsacrey | last post by:
Hello everybody, I've got a bit of a situation that I could use some guidance with if possible. I work for an auditing firm where my users audit electronic shipping data for customers to see if...
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
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
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.