Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL code or Visual Basic code

Posted on 2004-04-21
5
Medium Priority
?
276 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
4 Comments
 
LVL 17

Accepted Solution

by:
walterecook earned 252 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 248 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 51

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

876 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