473,394 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Append a table to another table

2
Hello,
I am still at the beginning of my learning process but already have some problems. I used Access long time ago, and some things changes, while I forgot a lot. So, here is my problem:
I have a table (Table1), which is supposed to be appended to a Table2. Table2 had 2 additional fields, in addition to the fields in Table1. Values for those two fields are in 2 text boxes on the form (txtStardDate and txtEndDate)
I know I have to write VBA where I will open database, and two recordsets, edit them, and make a look, but whatever I tried, did not work. Anybody had a code that will do something like this?
Many thanks.
Sep 14 '07 #1
4 1912
Scott Price
1,384 Expert 1GB
Why not look into an append query? Create a regular select query in design view, then right-click change to Append, and set the two extra values by referencing the text boxes: Forms![FormName]!txtStartDate Etc...

Regards,
Scott

p.s. you can also run an append query from vb code by using the DoCmd.RunSQL [ValidSQLStatement] route.
Sep 14 '07 #2
Shap
2
Thanks for the reply. That was my first idea, but thisngs are bit more complicated here. Simply append is not possible, since tex boxes are Text fileds, and fields in Table2 are Date type. So, I have to perform a CDate( ) in the meantime, and can not just refer to the form.
Still, I believe I have to go through the code, but have problems with ADO (how to open recordset, how to move through it, how to edit and save). I hope somebody will help me here.
Regards.
Sep 14 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks for the reply. That was my first idea, but thisngs are bit more complicated here. Simply append is not possible, since tex boxes are Text fileds, and fields in Table2 are Date type. So, I have to perform a CDate( ) in the meantime, and can not just refer to the form.
Still, I believe I have to go through the code, but have problems with ADO (how to open recordset, how to move through it, how to edit and save). I hope somebody will help me here.
Regards.
You don't need to use ADO. You can run an INSERT (append) statement from code.

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3.     strSQL = "INSERT INTO TableName (Field1, Field2, Field3, Field4) " & _
  4.         "VALUES (" & Me!IDField & ", '" & Me!SomeTextField & "', " & Me!SomeNumField & ", #" & Me!SomeDateField & "#)"
  5.  
  6.     DoCmd.RunSQL strSQL
  7.  
Sep 18 '07 #4
Scott Price
1,384 Expert 1GB
Thanks, Mary... This seems to have slipped through the cracks in my subscribed threads box :-(

As for using the CDate() function to change from text to date, this is easily done also by storing first into a variable, then calling the variable in the SQL statement.

I.e:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDate As Date/Time
  2.  
  3. MyDate = CDate(Me!TextBoxWithDate)
Regards,
Scott
Sep 19 '07 #5

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

Similar topics

2
by: John | last post by:
Hi - I am trying to perform a simple append query, with no luck. I have a table (MktPrices) that has the following fields: BondID, PriceDate, Price. The objective is to allow the user to input a...
2
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...
2
by: JMCN | last post by:
hi i have a general question regarding append queries in access 97. each week i need to update my table(tblonlinereg) with new or modified records. firstly, i import the text file into my...
2
by: Danny | last post by:
I want to extract a subset of fields from one table into another the master table has many fields the subset has about half, but still many. Is there a way I can just append the master into the...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
1
by: travismorien | last post by:
I have four tables of different "entities". One table contains information for "people", one for "trusts", one for "companies" and one for "self managed super funds". Each type of entity has an...
22
by: RayPower | last post by:
I'm having problem with using DAO recordset to append record into a table and subsequent code to update other tables in a transaction. The MDB is Access 2000 with the latest service pack of JET 4....
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
2
by: sj | last post by:
Situation: I have 2 tables, parent table (Invoice) and child table (InvoiceDetails) that is link by InvID in the child. Requirement: Need to do one-time append of information to another table...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
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...

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.