Greetings (again)...
This should be a simple matter but I cannot seem to find any information on how to do/build this.
Inside a single DB I have two tables... One is titled Employee Submissions and the other is Hours Archive.
What I need is a way to transfer records from the Employee Submissions table to the Hours Archive table based on the date associated with the field. Specifically I need any record older than 2 months to be transfered to the Hours Archive table. I also want the records in the Employee Submissions table to be deleted after the transfer.
Any thoughts?
8 1912
This should get you started: -
INSERT INTO [Destination Table] ( Field1, Field2, recordDate )
-
SELECT T.Field1, T.Field2, T.recordDate
-
FROM [Employee Submissions] T
-
WHERE (((T.recordDate)<=DateAdd("m",-2,Date())));
-
Every time I edit it with the specific information it comes back with an "Expected" error.
Here are the table Names: Employee Submissions Hours Archive
These are the fields (they are the same for both tables):
empName
Direct Hours
Indirect Hours
Other Hours
entDate
Other Details
Presence
this is the gist of the code I derived: - Private Sub Form_Open(Cancel As Integer)
-
INSERT INTO [Hours Archive] (empName, Direct_Hours, Indirect_Hours, Other_Hours, entDate, Other_Detail, Presence)
-
SELECT T.empName, T.Direct_Hours, T.Indirect_Hours, T.Other_Hours, T.entDate, T.Other_Detail, T.Presence
-
FROM [Employee Submissions] T
-
WHERE (((T.entDate)<=DateAdd("m",-2,Date())));
-
-
End Sub
The error is "Expected: end of statement" and highlights [Hours Archive]
I am sorry, every time you edit what? And what do you mean my specific information?
Did you adapt the query to your needs?
Sorry... Every time I open the form (Event Procedure) I get the error. Above is the adapted (at least what I derived and adapted) code.
As I have mentioned before, I'm not very good with VB, but there is no one else here familiar with Access to build this DB.
Of course, if you want to use this through a form it is not going to work as is. This will work if you paste it in the SQL editor of the query designer. Then you can save it and run it as a query.
If you want to use it in a form action event, go like so: -
Private Sub Form_Open(Cancel As Integer)
-
dim SQL as String
-
SQL = "INSERT INTO [Hours Archive] (empName, Direct_Hours" & _
-
", Indirect_Hours, Other_Hours, entDate, Other_Detail, Presence)" & _
-
" SELECT T.empName, T.Direct_Hours, T.Indirect_Hours" & _
-
", T.Other_Hours, T.entDate, T.Other_Detail, T.Presence" & _
-
" FROM [Employee Submissions] T" & _
-
" WHERE (((T.entDate)<=DateAdd('m',-2,Date())));"
-
DoCmd.RunSQL SQL
-
End Sub
-
Quick question... Will this string require a SQL server or SQL services to be running? If so, neither of them are running on this system.
When I try to execute this code it gives me the following error:
Run-time error '3134':
Syntax error in INSERT INTO statement.
When I run the debugger it highlights the DoCmd.RunSQL SQL Line (I'm assuming this is because this is the actual command that initiates the code)
What about your field names? Are they like Indirect Hours or Indirect_Hours?
If there is a space, you must enclose them in bracket : [Indirect Hours]
Never mind... I just got laid off so no more working on this DB... sorry to be such a bother...
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bryan |
last post by:
Hi, I have two tables. I want to update two columns in my first table,
and with two values and
held in my #temp table but based on a RUN_DATE from my first
table.
Can anyone point me in...
|
by: Niyazi |
last post by:
Hi,
I have BIG question and I gues it is the BEST question.
I have a problem that I am guessing the best solution is to create some sort
..NET Services.
This Service(s) must check every...
|
by: Woody Splawn |
last post by:
Lets say I have a winform that is populated with a dataset. The dataset and
data table may have several rows in it. Lets say I am looking at the
winform and I want to assign a value to a certain...
|
by: Chris S |
last post by:
I'm relatively new to VB.NET and have what's probably a very simple
question. I'm trying to get one form to access (view and modify) data on
another form. For example, the startup object is a...
|
by: Vasilis X |
last post by:
Here is the question :
I have a data table, UnShorted, which has a data column EventTime (type :
date time) and a data column Values (type : single).
I want to create a table, Shorted, that...
|
by: rfmatthews |
last post by:
I am not familiar with programming languages. I use Access because it
is simple to construct queries. PROBLEM: In a database used to
calculate employee payslips everything went smoothly on both...
|
by: coffeesin |
last post by:
Hi,
I have a Table containing these fields: id-no, cold, cold ever, cold date,flu,flu ever and flu date. (The properties of id-no, cold,cold ever,flu,flu ever are set as Numbers.)
What i want...
|
by: hexagram |
last post by:
hi guys can anybody can teach me how to do this scenario
Transfering Data of a form to a new form
The Scenario is:
I have a Delivery Receipt Form (Hardware) with a fields of the following
...
|
by: ivijayan |
last post by:
HI.
I have the following query:-
How do i create field which updates its contents on the basis of data in another field in same record.
especially if I have a Date field, how can I change the...
|
by: Ro |
last post by:
I've been given the task of transfering data from an access db to sql
server 2000. The previous access db was not structured very well so
we reconstructed the tables in sql server 2000 to add...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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: 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...
| |