Solved

SQL code or Visual Basic code

Posted on 2004-04-21
5
210 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now