473,396 Members | 1,996 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,396 software developers and data experts.

Creating New Records in one Table from another table

1
Ok, here's my problem...... I have a contacts table which includes, ID, FirstName, LastName, Category, Region, Date of Birth, etc. Then i have a Personal Details Table which lists their home addresses and a business table that lists their business addresses.

The problem is.... some of our contacts have their home addresses as preferred mailing addresses, others have their business addresses. I have a yes/no field in the table that says "MailingAddress?". When this checkbox is ticked i want a new record to be created in a table "tbl_MailingAddress"

Any ideas would be much appreciated, and please be gentle....it's been a while since i used Access and VBA.

Thanks
Bec :-)
Mar 27 '07 #1
1 1431
Ok, here's my problem...... I have a contacts table which includes, ID, FirstName, LastName, Category, Region, Date of Birth, etc. Then i have a Personal Details Table which lists their home addresses and a business table that lists their business addresses.

The problem is.... some of our contacts have their home addresses as preferred mailing addresses, others have their business addresses. I have a yes/no field in the table that says "MailingAddress?". When this checkbox is ticked i want a new record to be created in a table "tbl_MailingAddress"

Any ideas would be much appreciated, and please be gentle....it's been a while since i used Access and VBA.

Thanks
Bec :-)




why dont you use the add new method for the recordset object.
for example:

Expand|Select|Wrap|Line Numbers
  1. Dim myConnection As ADODB.Connection
  2. Dim tbl_MailingAddress_Table  As New ADODB.Recordset
  3.  
  4. Set myConnection = CurrentProject.Connection
  5. tbl_MailingAddress_Table.ActiveConnection = myConnection
  6.  
  7. tbl_MailingAddress_Table.CursorLocation = adUseClient
  8. tbl_MailingAddress_Table.CursorType = adOpenDynamic
  9. tbl_MailingAddress_Table.LockType = adLockOptimistic
  10. tbl_MailingAddress_Table.Open "tbl_MailingAddress", , , , adCmdTable
  11.  
  12. tbl_MailingAddress_Table.AddNew
  13. tbl_MailingAddress_Table.Fields(0) = value of field one
  14. tbl_MailingAddress_Table.Fields(1) = value of field two
  15. tbl_MailingAddress_Table.Fields(2) = value of field three
  16.  
  17. ...........and so on..............
  18. tbl_MailingAddress_Table.Update
  19.  
  20. tbl_MailingAddress_Table.close
  21. Set tbl_MailingAddress_Table = Nothing
  22. Set myConnection = Nothing

The code is general at the moment, make sure to study it and fix it to fit your needs,
with something like that code you can take anyvalue you want add it to the recordset (Table you want) and then its saved when the update method is used.
This is how i do it atleast :)


Hope this helps you,
Christina
Mar 27 '07 #2

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

Similar topics

31
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
7
by: John Baker | last post by:
Hi: I would like to know how to create a temp DB to store the data in a table while I do something else with the table. Specifically, how do I create the temp remove the temp I want to be...
5
by: Mike Turco | last post by:
What is the difference between creating relationships in the front-end vs. the back-end database? I was trying to create a relationship in a database front-end and noticed that I could not check...
4
by: | last post by:
This is blowing my mind because I thought this setup was working.... How is a new record generated in the table of a Child subform whenever a new record is generated in the table of the Master...
6
by: F-13 | last post by:
I'm working on a BOM in Access 200 from an example downloaded from from the web. The sample database contains three tables, Assemblies (the list of items needed to assemble any assembly),...
7
by: rcamarda | last post by:
I wish to build a table based on values from another table. I need to populate a table between two dates from another table. Using the START_DT and END_DT, create records between those dates. I...
3
by: CanFlightSim | last post by:
I am not very strong in databases, so you must forgive any obvious stupidity. After having a good look at our Sales Managemend database, we decided there is something basially wrong. Our Agents...
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
5
by: tech.rawsteak | last post by:
I have a function that retrieves a user's login name from their workstation and looks it up on an employee table to return their full name (ie: jsmith -John Smith). Their full name is then...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...

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.