473,653 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Just a query - Moving entry from 1 table to another

I know I could probably write something along the lines of the below to do
this but, am hoping there's an easier way.

Basically what I am wanting to do is, select an entry in 1 table, then move
it to another. However, at the same time, in the second table, find all the
entries marked "Yes" in the "New" field, and change the oldest one to "No".

What I was thinking, was something along the lines of;

'// 1st table
rst.Open "Select * From tblMain Where ID = '" & strID & "'", DB,
adOpenStatic, adLockPessimist ic
strTempID = rst("ID")
strTempField1 = rst("Field1")
'//..... all the way to the last field

'// 2nd table
rst.Open "Select * From tblNew", DB, adOpenStatic, adLockPessimist ic
rst.AddNew
'// as the ID from the first table is most likely going to be taken
'// I'll just ignore strTempID, and add it as I would any other
rst("ID") = rst.RecordCount + 1
rst("New") = "Yes"
rst("Field1") = strTempField1
'//..... all the way to the last field
rst.Update

'// Locate the oldest entry that still has it's "New" field marked "Yes"
'// And change it's "New" field to "No"
rst.Open "Select * From tblNew", DB, adOpenStatic, adLockPessimist ic
Do Until rst.EOF
If rst("New")="Yes " Then
'// This is where I'm now stuck.....
End If
rst.MoveNext
Loop

Apologies if this makes no sense, I've just woken up....... but this is
bugging the life out of me, so any advice would be appreciated.

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


Jul 19 '05 #1
1 1251
Nevermind..... figured it out :o) (all I needed was a caffiene hit, hehe)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Steven Burn" <pv*@noyb.com > wrote in message
news:un******** *****@tk2msftng p13.phx.gbl...
I know I could probably write something along the lines of the below to do
this but, am hoping there's an easier way.

Basically what I am wanting to do is, select an entry in 1 table, then move it to another. However, at the same time, in the second table, find all the entries marked "Yes" in the "New" field, and change the oldest one to "No".
What I was thinking, was something along the lines of;

'// 1st table
rst.Open "Select * From tblMain Where ID = '" & strID & "'", DB,
adOpenStatic, adLockPessimist ic
strTempID = rst("ID")
strTempField1 = rst("Field1")
'//..... all the way to the last field

'// 2nd table
rst.Open "Select * From tblNew", DB, adOpenStatic, adLockPessimist ic
rst.AddNew
'// as the ID from the first table is most likely going to be taken '// I'll just ignore strTempID, and add it as I would any other
rst("ID") = rst.RecordCount + 1
rst("New") = "Yes"
rst("Field1") = strTempField1
'//..... all the way to the last field
rst.Update

'// Locate the oldest entry that still has it's "New" field marked "Yes" '// And change it's "New" field to "No"
rst.Open "Select * From tblNew", DB, adOpenStatic, adLockPessimist ic
Do Until rst.EOF
If rst("New")="Yes " Then
'// This is where I'm now stuck.....
End If
rst.MoveNext
Loop

Apologies if this makes no sense, I've just woken up....... but this is
bugging the life out of me, so any advice would be appreciated.

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Jul 19 '05 #2

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

Similar topics

5
5310
by: Stephen Miller | last post by:
Hi, I am trying to add a staggered running total and average to a query returning quarterly CPI data. I need to add 4 quarterly data points together to calculate a moving 12-month sum (YrCPI), and then to complicate things, calculate a moving average of the 12-month figure (AvgYrCPI). Given the sample data:
2
5781
by: JMCN | last post by:
hi i need some advice on whether if it would be better to use an append query or an update query. here is the situation, i have linked another database table to my current database. then i created a query for the linked database but eventually i need to have this query to be constantly updated and append to another table in the current database. i hope i'm not too vague but i have no idea if i should use an update or an append query....
1
3199
by: ravi | last post by:
I have created the following interest to calculate the interest for the following currency pairs. I have tried to combine them in macros using conditions but the next query that is run in the macro ends up deleting the previous interest value that has been generated by the query. For example if query 1 is run on the table with currency pair USD/CHF then the interest will be updated without any problem but if there is another entry in the...
13
1743
by: Maxi | last post by:
I have a table (Table name : Lotto) with 23 fields (D_No, DrawDate, P1, P2,.....P21) and it has draw results from 1st Sep 2004 till date. I have another table (Table name : Check) with 15 fields (F1,F2,....F10, R6, R7, R8, R9, R10). I have few lacs combinations of 10 numbers in the Check table in the first 10 fields F1-F10). I want to check how many numbers from the first combination (record1 of Check table, fields F1-F10) matched in...
3
2093
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance you can provide. I have a table in an Access 2000 .mdb file, and I've run into something odd and insolvable, at least for me. The database is for membership information. This particular table, called tblMembershipInfo, has fields/columns as follows - fldMemNum - Member Number fldActionDate - The date when the entry was made in that row - Data type is Date/Time, no format specified
3
1931
by: corear | last post by:
I have a new case tracking system. The cases table has these fields: CaseID (Primary Key) StatusID (looked up in another table - Open, Pending, or Closed) Status Comment (memo field) Date&Time (when casse was opened) ProjectID (looked up in another table - various projects are listed there) CustomerID (looked up in another table - list of names and other info for each) Request (memo field) Result (memo field)
5
1471
by: kkddrpg | last post by:
the database looks like this the database is called username_tpp (not really just using username as a sub) the table is called home it has field 1 : varchar(50) | latin1_swedish_ci | no attributes | null = no | default = (nothing) | extra = (nothing) | action = primary key | comments = h
9
3048
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
0
1914
by: jvitti | last post by:
I recently upgraded from Access 2000 to Access 2007 and I am having trouble with moving the focus from 1 form to another. While doing data entry if a similar claim is found the claim view form will open listing the similar claims. The data entry clerk can view 1 of the claims and by doubling clicking on the claim number some info from the claim view will be used to populate fields on the data entry screen. The following code is used...
0
8283
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
8704
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...
1
8470
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
8590
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
7302
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
6160
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...
1
2707
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
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
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.