How To Copy Records To Different Table

Jun 22, 2006

Hi all

This gonna be a long one.... I've search the whole forum for answer to this problem, but couldn't find the one suitable enough.

I have a quote table with the following field:


QuoteName
QuoteDescription
QuotePrice

and booking Table:


BookingName
BookingDescription
BookingPrice

The real table is much more complex, but this will do for now.

When a client call up for a quote, their request will be added into the "QuoteTable". One name can occur many times depend on how many they ask for quote. Once they decided to proceed with the booking, all the records need to be transfered into "BookingTable".

Currently, I use either one of the following codes found in this forum:


Dim dbs As DAO.Database
Dim rstQuote, rstBooking As DAO.Recordset

Set dbs = CurrentDb
Set rstQuote = dbs.OpenRecordset("SELECT * FROM QuoteTable " & _
"WHERE QuoteName = ' " & Name & " ' ")
Set rstClient = dbs.OpenRecordset("BookingTable")

Do Until rstQuote.EOF
rstBooking.AddNew
For Each Field In rstQuote.Fields
rstBooking.Fields(Field.Name).Value = _
Nz(rstQuote.Fields(Field.Name).Value, "")
Next Field
rstQuote.MoveNext
rstBooking.Update
Loop


or


Dim lngOuterCounter, lngInnerCounter As Long
Dim dbs As DAO.Database
Dim rstQuote, rstBooking As DAO.Recordset

Set dbs = CurrentDb
Set rstQuote = dbs.OpenRecordset("SELECT * FROM QuoteTable " & _
"WHERE QuoteName = ' " & Name & " ' ")
Set rstClient = dbs.OpenRecordset("BookingTable")

If Not rstQuote.EOF And Not rstQuote.BOF Then
rstBooking.AddNew
For lngInnerCounter = 0 To rstQuote.Fields.Count - 1
rstBooking.Fields(lngInnerCounter) = _
Nz(rstQuote.Fields(lngInnerCounter), "")
Next lngInnerCounter
rstBooking.Update
End If


But none seem to work. Can anyone help?


Cheers
arnodys

View Replies


ADVERTISEMENT

Modules & VBA :: Copy Records To 2nd Table

Mar 28, 2014

I'm getting myself into a bit of a muddle.

I have four tables:
tblinvoice / tblinvparts
tblquotes / tblquoteparts

when I open the tblinvoice form it has tblinvparts as a subform. tblinvoice has a listbox that lists quote numbers linked to vehiclereg. I have a button on the tblinvoice that will open a popup tblquoteparts continuous form linked to the quoteid on tblinvoice. These filtered records have a select button so I can select all or some.

I have now got stuck as I need a button on tblquoteparts popup that will copy the selected records from tblquoteparts and paste them into tblinvparts where quote (on tblequoteparts)=quoteid in tblinvoice.

In a nutshell, I would like to copy selected records from tblquoteparts to tblinvparts.I need to duplicate the records because only 10% of invoices are generated from a quote and the quote parts/prices may differ from the final invoice.

View 9 Replies View Related

Linked Table, Cannot Copy/paste New Records

Feb 16, 2006

I have an Access database with linked tables from Sybase SQL Anywhere, via an ODBC data source. I have just linked the tables recently, all the data used to be in native Access tables. It is fairly common for members of our team to open these tables in datasheet view, and copy/paste several records to create new records, then edit a few fields on the new records. This used to work fine with native Access tables, but when we try it with the linked tables we either get an ODBC error - "primary key value already exists" or the new records show up with #Deleted.

The root of the problem is this: In the old Access tables, the primary key was an autonumber field, and Access was smart enough to assign new ID's when you copy/pasted records. In the linked table, the primary key is type "Number" in Access, and Access is not smart enough to let Sybase assign new ID's when you copy/paste records in datasheet view. Access is trying to force the existing ID's into the primary key field, and Sybase says "too bad so sad".

Of course, I could just write some quick append queries to copy/paste the data. And in the short term, that's exactly what I will have to do. But is there any way, long term, to allow members of my team to do it the "quick & dirty" way by copy/pasting in datasheet view? I have tried to change the primary key to an autonumber field in design view, but Access doesn't allow that. Is there a way to do it in code, or a way to force Access to allow Sybase to always handle the primary key field?

View 1 Replies View Related

Queries :: Unable To Copy Records Into Another Table

Sep 7, 2013

I'm using Access 2007.

I have a button on a form that when clicked, does the following:

I have a table called [Workorder Parts] that has 128 records in it with Fields named WorkOrderPartID (Autonumber), WorkorderID(Number), PartID(Number), Quantity(Number), UnitPrice(Currency), Notes(Memo), KitID(Number).

I want to copy records into another table called [tKitsWorkorderParts] that has the identical structure based upon a value in the field WorkorderID. For testing purposes let's assume that the field contains the value "12". There are 28 records in the table that have the value set to "12"

If I hardcode the value "12" into the following SQL statement, it finds and copies the 28 records correctly.

DoCmd.RunSQL "INSERT INTO [tKitsWorkOrderParts] SELECT * FROM [WorkOrder Parts] WHERE [WorkOrder Parts.WorkOrderID] = 12"

so far so good.....

Now, on the form there is a Text Box called WorkorderID that contains the value "12".

If I change the code to the following, I get all 128 records instead of just the 28 I am expecting:

DoCmd.RunSQL "INSERT INTO [tKitsWorkOrderParts] SELECT * FROM [WorkOrder Parts] WHERE [WorkOrder Parts.WorkOrderID] = WorkorderID"

I have inserted a few MsgBox displays to display the value contained in WorkorderID and it shows "12"...

What am I doing wrong???

View 2 Replies View Related

Modules & VBA :: Macro To Copy Records From One Table To Another

Jun 22, 2015

I have two tables in my Access database, their fields are exactly the same (for now). One table is called Uncheched. The other one is called Checked. So what is need is a macro that takes selected records in table Unchecked and copies them to the end of table Checked. Actually CUTS from Unchecked and PASTES to the end of Checked table.

Sub MoveRecords()
DoCmd.RunCommand acCmdCut
DoCmd.OpenTable "tblChecked", acNormal, acEdit
DoCmd.GoToRecord , , acLast
DoCmd.RunCommand acCmdPaste
End Sub

View 13 Replies View Related

Queries :: Insert Into - Copy Records From Another Base Into Existing Table

Apr 15, 2014

I'm trying to copy records from another base into existing table in current base by:

Code:
DoCmd.RunSQL ("INSERT INTO pivot (RFO_CLIENT_ID, FOLDER_DATE_CREATE, start_time, end_time) SELECT (RFO_CLIENT_ID, FOLDER_DATE_CREATE, start_time, end_time) FROM svod IN 'Z:NPSNPS - Operator - 1.accdb' ")

But it doesn't run. Says insert into syntax error.

View 6 Replies View Related

Copy Records From Split Form Datasheet Section To Another Table?

Dec 13, 2011

I have a split form (frmPatient Schedules) that shows me my records in the datasheet view at the bottom section of the form. My records have a field with a checkbox (ckbxHOLD).how can I get the records that don't have their checkbox checked to be copied as new records to a different table (tblHome Visits)?

View 9 Replies View Related

Modules & VBA :: Table Relationships And Nested Forms - Copy Sub Form Records

Aug 3, 2015

I've attached screenshots of the table relationships and some nested forms that I need to discuss in my database.

If you look at the forms screenshot you'll see I have a main form "business/cmc issues" that uses a combo box to select a business name; nested into that I have a second form "policy issues log" that holds details of policy issues about that business; then inside that I have a sub form "issue updates" that records brief details about the actions carried out in trying to resolve each policy issue.

The same policy issue can affect more than one business (because of a relationship between the two companies etc) but still needs to be viewed separately. So for example in the business selector combo box I might have business "ABC". In the policy issue it might say "doesn't pay on time". The "doesn't pay on time" issue might also apply to business "123" and so if I picked that business from the combo box you'd see the same policy issue.

Because it's the same issue for two separate businesses, the actions carried out will be the same, so what I want to do is, after a new action is carried out (where relevant) to be able to click a button that would run some code that copies the actions entered in the sub form for business ABC and pastes them into the sub form for business 123 where the product area and policy issue are equal. This is to avoid having to enter the same data twice.

View 3 Replies View Related

Copy Existing Fields To New Records

Dec 12, 2006

I have a database and I wish to be able to copy 10 out of about 20 fields into a new record automatically using a command button on a form. Similar to the way the Duplicate button or the Create New button would work but only with these selected fields. None of the fields I wish to duplicate are the primary key. The primary key is an AutoNumber field. After clicking the Save button, the primary key would increment one to confirm the save record.

Any help or suggestion would be appreciated!

Thanks!

View 3 Replies View Related

General :: Copy Database With No Records

Aug 6, 2013

I'd like to be able to show recruiters the database as an example of my work (to get an interview, etc.). Of course, I can't just show them a copy of the database with all of the private information on it, so I'd like to be able to show them a copy of the database with no records. Is there a way to export/copy it so I can do this in Access 2007?

View 4 Replies View Related

How To Copy Linked Records (append Query?)

Jan 16, 2008

I have attached an image of the 2 tables concerning my question.

The main "transaction" table is the tblAssessments and a linked table tblRisks drives a subform - showing multiple Risks per assessment.

The field "OccupantID" identifies the facility where Assessments are done (there are other tables, of course).

I am using an OccupantID "00000" to store templates - pre-filled assessments with most common options selected.

I am trying to develop code and/or query or SQL that would do this:

copy all templates (records from OccupantID 00000) and corresponding sub-records from tblRisks into the same tables, but under a different (selected by user) OccupantID.

I have no problem just using an Append Query (actually a SQL statement in VBA with variable parameters), but that only lets me copy into 1 table - so I can copy just the tblAssessments records.

but how do I then copy the tblRisks related records and make sure I attach them to the correct AssessmentID?

View 5 Replies View Related

Forms :: Copy Fields To Multiple Records?

Jul 17, 2015

I have this access "Database" that contains only one table that I'm trying to make a form for. I want it to allow the user to enter a value for field A and a value for field B then a list of values for field C (which is the key, so each would be a new record all with the same values for field A and field B). I tried to make a multiple item form but when I click on the new row for field C, fields A and B both disappear.

Disclaimer: I know that the creation of a one table database is a mortal sin but that's what my boss gave me and there are already >8000 records with a million mispelled words, so I don't think there's much I can do to make it a relational database without entering each record in again.

View 4 Replies View Related

General :: Copy Data From Local Access Table To Linked SQL Server Table?

Jan 13, 2014

I have an MS Access accdb with linked SQL Server 2012 ODBC tables. I am working on a procedure to copy data from local tables to these linked tables (identical schema). I did a simple

Code:

DoCmd.RunSQL "INSERT INTO linkedTable SELECT * FROM localTable"

This works, but is very slow. Way too slow. (INSERT copies the data one record at a time).

I would like to copy the data in a bulk operation, or operations that I can execute programmatically.

View 1 Replies View Related

Modules & VBA :: Copy Record To History Table And Then Delete It From Main Table

Jul 9, 2014

I have a form with a sub form. when a record is choosen in a combo box the sub form is filled out with a record.

what I am trying to do is have a button that will copy that record to a history table then delete it off the the main table.

I cheated by using the wizard to get the code to delete the record but I am having troubles modifying the code to copy that record to the history table. Here is the code below. I have tried to insert code in several places but it just errors out.

'------------------------------------------------------------
' Master_tbl_sub_fm
'
'------------------------------------------------------------
Function Master_tbl_sub_fm()
On Error GoTo Master_tbl_sub_fm_Err
With CodeContextObject
On Error Resume Next

[Code] ....

View 8 Replies View Related

General :: Copy And Paste Records With Current Date

Sep 24, 2013

I have a database that is tracking donations for my organization. I have some members who donate the same amount every month. Is there away to copy the records and paste them with the current date in the "Date Paid" field, and do this "Update" once a month? As opposed to typing in 200 records each month? I would assume that I would have to run an update query which filters to just the members that pay each month, but the big question is how to copy and paste these records. I am using Access 2010, I have some VB ability, but not an expert by any stretch. My SQL is not strong at all either.

View 3 Replies View Related

Forms :: Comment Box To Copy To The Rest Of Queried Records

Jan 13, 2015

Here is my code...if I take out the where statement..it copies the remarks all the way down my table to all the records...with the where statement..it's prompting in for parameters..

Private Sub Remarks1_Click()
Dim strMsg As String, strQry As String, strRemark As String
strMsg = "Update All Comments in the Current view. IMPORTANT!!! Will update a the Viewed records."

[Code].....

View 2 Replies View Related

Forms :: Create A Button To Copy Records From One Of Subforms

Jan 26, 2015

I have a form with several subforms for entering information while surveying rooms in a building. I am trying to create a button to copy records from one of the subforms if the data is the same (for example if there are 3 types of flooring in multiple rooms) and append it into the same subform with a different space ID. I can not get it to recognize the Space ID on the current record. This is what I have in the command button code:

Private Sub AppendFloorCmd_Click()
Dim FloorTypes As String, SpaceUpdate As String
Dim CurrentSpace As TextBox
Set CurrentSpace = Me.SpaceID
FloorTypes = "INSERT INTO FlooringSurveyTable (FlooringHomoID)" & _
"SELECT FlooringSurveyTable.FlooringHomoID FROM FlooringSurveyTable " & _
"WHERE (((FlooringSurveyTable.SpaceID)=[Enter Space ID to copy]))"

[code]....

When I click the button, it appends the right records but makes me type in the current space ID - I've tried a bunch of ways of naming that control, but it will not work.

View 7 Replies View Related

Forms :: Loop Through Records And Copy One Of Fields For Each Row Into Another Subform

Apr 12, 2013

I have a subform for which I want to loop through all the records and then copy one of the fields for each row into another sub form.

I came up with the bellow code but i get an error when I run it.

The error is an "error 438".

Code is at follows and I am copying the field called price:

Do Until Forms![Roll Out - Site Form]![Roll Out - Sign items pick list].EOF
[Roll Out - Sign items added].Form![Price] = [Roll Out - Sign items pick list].Form![Price]
Forms![Roll Out - Site Form]![Roll Out - Sign items pick list].MoveNext
Loop

View 4 Replies View Related

Modules & VBA :: Copy Structure Of A Table To Make A Temp Table

Apr 20, 2015

I'm trying to copy the structure of a table to make a temp table. I'm using CopyObject (which also copies the data). So when I delete the data from the temp table, it also deletes data from the source table. Is the data linked? It should just be deleted from the temp table. Below is the beginning of the code. I've stepped through, and at the last step shown, the data in the source table deletes.

Code:
Dim strFile As String
Dim temp As String
Dim tbl As String
Dim db As DAO.Database

' error handle
On Error GoTo F_Error

[Code] .....

View 3 Replies View Related

Tables :: Copy And Replace Existing Records Function In Access?

Dec 3, 2012

Is there a copy and replace existing records function in access?

I.e. I would want to copy records from one table to another (with same structure) and replace similar records with in original table in the new records (which have minor ammendments made).

View 3 Replies View Related

Tables :: Copy And Paste Text Field To Multiple Records

Aug 10, 2015

I have been unable to find a simple way to copy a text entry from a Table Field and paste it to multiple records in Datasheet view.The Toolbar 'Paste' procedure copies to the selected record only and I am unaware of how to select multiple records, as per a spreadsheet procedure.

View 2 Replies View Related

Active Table And History Table, How To Copy On Deletion?

Feb 14, 2006

My 2nd post, and I am very new to DB and Access. I have a problem that I want to get help on. I want to set up a main form that is used to enter and delete all data for my table. I wish to add either a button or to make it automatically happen when a record is deleted, that it is first copied to a separate table with the same fields, except it also has a closed date that would be the date that the record was copied over. I know zilch about VB, VBA or any other language other than AutoIt, so assume I am what I am, an ignorant beginner.

I did look into the event somethihng like upondeletion or something... while trying to find help on this in the access and VBA parts of Office, but I do not know how to utilize the event with Basic or SQL, which I know none of either.

Any help or examples are very much appreciated.

**EDIT**
I do not require all fields to be recorded to the secondary DB (History), so if someone can just give me an example of how I would move two fields to a separate DB, I can hopefully learn enough from it to do more.

Thanks a Bunch!


EXAMPLE**
Current Loans (Table 1):
CustomerID
Name
Address
City
State
Phone

Customer History (Table 2):
CustomerID
Name
Phone

That gives an example to help understand what I need. I want to store the CustomerID, Name and Phone values of the record being deleted, to the History Table, which I am using as a closed account table for later look up.

View 14 Replies View Related

Creating A Database To Store Training Records That Saves A Scanned Copy

Jun 8, 2015

I'm a access novice who is looking to create a database to store training records for permanent and agency staff, and contractors staff. I need the database to be able to produce reports on how many courses were trained over each month, and the total duration of the course completed (in hours).

View 2 Replies View Related

Automate Copy Table And Sequence Table Name

Oct 27, 2004

I have a user who wants to automate copying a table from our main database. Basically, he is naming the new table with the original table name and the current date. For example, Part_Table_9-3-04, Part_Table_9-4-04, Part_Table_9-5-04 etc for each day of the month.

He wants me to write a macro, module, or vb code that automates the steps.

I have DoCmd.CopyObject,"Table1",AcTable,"Table2" I want to concatenate the date function (now) or (today) with the new table name but can't seem to get this to work.

Any suggestions?

Thanks for helping,

Jeff

View 3 Replies View Related

How To Copy All Record On A Table To Another Existing Table?

Feb 3, 2005

I have a table with employees’ information. I want to copy all records in this table to another existing table “WorkTimes”. I do not want to edit my employee table, so therefore I want to copy all records to another table before editing/adding information in other fields. How I can do that with a macro or module?

Thanks in advance.

View 3 Replies View Related

How To Copy A Column From One Table And Insert It Into Another Table In The Same Db

Feb 3, 2006

How to copy a column from one table and insert it into another table in the same database

Hi, All,

I have two tables (old and new) sitting in the same database. The new table is the result of 'data cleansing' done by an external company. In the process (export and import via excel) two memo type colums in the table were truncated in excel.

To make the new table usable, I must therefore now copy/insert the two memo columns from the old table into the new table.

Both tables are already Access tables and sit in the same database. Both tables, of course, have the same number of rows.

I tried to high-light one column in the old table, clicked copy, then high-lighted a blank column in the target table, then clicked Paste, but got error msg: "This text is too long for this field. Try copying a shorter text", as if I had wanted to copy the whole column into one cell rather than one column into another column of equal length.

What is the best way to proceed?

Thanks for your help.

Adrian

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved