Solved

SQL code or Visual Basic code

Posted on 2004-04-21
5
228 Views
Last Modified: 2013-11-25
I need either SQL code or Visual Basic code to populate 2 junction tables (associative tables) in a patient treatment plan database.  

I need to insert (or add) the Patient# from the patient table and the DD_CODE_ID from the DD_CODE table into the Patient_DD_Code table.  And insert (or add) the Patient# from the patient table and the TX_Category_ID from the TX_Category table into the Patient_TXCategory table.

Do I write this code in a query or on a form with a command button?  I'm not sure where to write the code for this.

Thanks for any help you can give me.

tlm17
0
Comment
Question by:tlm17
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
walterecook earned 63 total points
ID: 10880873
The quickest way would be to do both.
Create queries that would actually move the data (append queries)
Then you can have this code on a command button:
docmd.setwarnings false  ' turn off the notify
docmd.openquery "query1Name"
docmd.openquery "query2Name"
docmd.set warnings true ' notify back on (good idea)

Does that help?
Walt

0
 
LVL 18

Assisted Solution

by:Data-Man
Data-Man earned 62 total points
ID: 10881048
if you want the queries to run faster use the execute method of the currentdb object


CurrentDb.Execute "query1Name", dbFailOnError
CurrentDb.Execute "query2Name", dbFailOnError

Using the execute method negates the need for the two setwarnings statements.

Mike
0
 
LVL 17

Expert Comment

by:walterecook
ID: 10881164
Sure does.  Good idea dataman.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 11956607
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

Split - walterecook,Data-Man

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

RoutineT
EE Cleanup Volunteer

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question