473,795 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pull info from two tables and and a query

158 New Member
I've got two tables tblPatient and tblIV. I have the PatientWeight in tblPatient, PatientAge in qryCalcPatientA ge, and IJEE in tblIV. What i am needing to do is get the weight and age from the table and multiply them together to get the IJEE. I'm using VBA is it possible?!? if not how would I go about doing this?
Thanks for input

Matt
Apr 27 '08 #1
5 1687
PianoMan64
374 Recognized Expert Contributor
I've got two tables tblPatient and tblIV. I have the PatientWeight in tblPatient, PatientAge in qryCalcPatientA ge, and IJEE in tblIV. What i am needing to do is get the weight and age from the table and multiply them together to get the IJEE. I'm using VBA is it possible?!? if not how would I go about doing this?
Thanks for input

Matt
The easist way to deal with that is to make it part of the query. When you create your select statement, you include your equations along with it.

I can get any more detail of an answer without having table structure and fields listed out.

Hope that help,

Joe P.
Apr 27 '08 #2
Jollywg
158 New Member
Joe thanks for the reply,
tblPatient and tblIV are joined by PatientID key. qryPatientAge is joined to tblPatient with PatientID as well. How would I go about writing sql for that query here is what i tried, but it kept giving me errors. (tblIV.Trauma is a checkbox on a form)
Expand|Select|Wrap|Line Numbers
  1. SELECT tblIV.Vent, tblPatient.Gender, tblPatient.[WeightKG], tblIV.Trauma, qryFindAge.PatientAge, 
  2.  
  3. (If (tblIV.Trauma = true) THEN INSERT INTO tblIV.IJEE (tblPatient.Weight * qryFindAge.PatientAge)) END IF
  4.  
  5. FROM (tblPatient INNER JOIN tblIV ON tblPatient.PatientID=tblIV.PatientID) 
  6. INNER JOIN qryFindAge ON tblPatient.PatientID=qryFindAge.PatientID;
Again thanks for the help
Apr 27 '08 #3
PianoMan64
374 Recognized Expert Contributor
Joe thanks for the reply,
tblPatient and tblIV are joined by PatientID key. qryPatientAge is joined to tblPatient with PatientID as well. How would I go about writing sql for that query here is what i tried, but it kept giving me errors. (tblIV.Trauma is a checkbox on a form)

SELECT tblIV.Vent, tblPatient.Gend er, tblPatient.[WeightKG], tblIV.Trauma, qryFindAge.Pati entAge,

(If (tblIV.Trauma = true) THEN INSERT INTO tblIV.IJEE (tblPatient.Wei ght * qryFindAge.Pati entAge)) END IF

FROM (tblPatient INNER JOIN tblIV ON tblPatient.Pati entID=tblIV.Pat ientID)
INNER JOIN qryFindAge ON tblPatient.Pati entID=qryFindAg e.PatientID;

Again thanks for the help
Well Jollywg,

The reason it is not working at all is your syntax for a select statement is wrong. The second thing that you need to understand is that don't get in a habit of storing calculated field into another table, because the problem comes in when you change the values. Then you have a problem.

For example:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblIV.Vent, tblPatient.Gender, tblPatient.[WeightKG], tblIV.Trauma, qryFindAge.PatientAge, IJEE:=IIF([tblIV.Trauma],tblPatient.Weight * qryFindAge.PatientAge,0)
  2. FROM (tblPatient INNER JOIN tblIV ON tblPatient.PatientID=tblIV.PatientID) 
  3. INNER JOIN qryFindAge ON tblPatient.PatientID=qryFindAge.PatientID
  4.  
Apr 28 '08 #4
NeoPa
32,579 Recognized Expert Moderator MVP
...(tblIV.Traum a is a checkbox on a form)..
This is going to sound argumentative, but "No it isn't!"
tblIV.Trauma must be a field in a table ([tblIV]). It is possible that you have a separate control on a form bound to this value. It's even possible it's called [Trauma]. Not tblIV.Trauma though.

Why don't you post your table meta-data for us and try to explain more clearly what you're after. Maybe we can help some more in those circumstances. This will work much better if you can post the meta-data (info about the layout / structure) of the table in the same way as I use in my example. Click on the Reply button and you will have access to all the codes I've used.
Expand|Select|Wrap|Line Numbers
  1. Table Name=[tblStudent]
  2. Field; Type; IndexInfo
  3. StudentID; AutoNumber; PK
  4. Family; String; FK
  5. Name; String
  6. University; String; FK
  7. Mark; Numeric
  8. LastAttendance; Date/Time
Apr 30 '08 #5
NeoPa
32,579 Recognized Expert Moderator MVP
I'm afraid this question was double-posted by the OP and the other thread (Tables VBA Code) had a helpful answer in it. Chronology would have been very confusing had the threads simply been merged.
Apr 30 '08 #6

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

Similar topics

0
1369
by: Patrick Crowley | last post by:
I'm creating a tool to browse a database of movie listings. The browser pulls up 25 results at a time, and you can page through them using 'Next' and 'Prev' tools. Pretty basic stuff. Here are my tables: movies directors comments movies_directors movies_comments
2
1179
by: rong.guo | last post by:
Greetings! I have the 3 raw data tables below, and would like to extract some data. My current query is really cumbersome, does anyone know a better way to get all the info (attach the right state to the lowest zip code) in one step? Thanks a lot! Here are the details. - Ideal Output, for each person , keep (1) person_id (From Table A) (2) The earliest open_date of accounts starting with 2 (From Table A)
5
7259
by: Julia Baresch | last post by:
Hi everyone, I haven't found any reference to this problem on this group or in Access 97 help. I hope someone here knows this - probably a simple thing, but not obvious. I designed a query to pull payment data from my database for accounting. It has 3 tables with one-to-many joins: Table1 --> one-to-many --> Table2 --> one-to-many --> Table3 The payment amount field is in Table3. I entered a few negative
4
2482
by: Joe Van Meer | last post by:
Hi, Is the datalist meant for one table or can I use it to display information from 2 different tables? Or should I be looking at a datagrid instead? I began my code and kinda ran into a snag where my last two columns I am displaying are ID fields, one for clientid and the other for empid. What I would really like is to display their actual names instead of the ids.
5
1771
by: The Cool Geek | last post by:
I'm building a dynamic site that has 3 data bases. One DB contains all of my store info ID#, Name, Address, Phone. Another DB contains member info ID, Name, address, email,phone,etc... The 3rd DB Tracks when a user logs in and logs out at a store. This DB has the following columns Store ID, Member ID, log in time,log out time, time in store. The stores log in in the morning that starts a session-I need the session to pull the store's...
4
1941
by: sparks | last post by:
We have a new project here, one that I have never tried maybe its easy I don't know yet. We have people that have records dating back over 5 yrs on a sql server. We have to build an access 2003 database for data entry of the people then pull data from the sql server to fill in data for these records. that sounds good....except to start I need record # and date....no problems there.
6
2292
by: RoomfulExpress | last post by:
Here's the problem that I'm having- I'm trying to pull in 2 fields from my database and place them in the title of the HTML. I'm connecting to the db and selecting everything exactly the same as I am doing below, and it works fine. For some reason it's not pulling in the fields. Any ideas? Here's the link to the actual page I'm working on. http://www.roomfulexpress.com/newsite/php/familyprofile.php?FAMILY_CD=558167959 Please see below...
3
2442
by: jmckown | last post by:
I'm attempting to pull a list of Google search terms from url's stored in a database. Here is an example of the data in the table I'm dealing with http://www.google.com/search?hl=en&q=proxy http://news.google.com/news?hl=en&q=proxy&um=1&ie=UTF-8&imgefp=Q-gUBRtWxEsJ&imgurl=cache.boston.com/resize/bonzai-fba/Globe_Photo/2008/06/19/1213929665_4899/539w.jpg http://www.google.com/search?hl=en&q=proxy I have written a query that gets me...
2
3903
by: amit2781 | last post by:
Hi, I have created 4 tables in 'amit' database and then I deleted them. Still I able to get information about the table_schema for the table deleted. After drop table when I fire a query for table_schema from information_schema.tables it will give me result as 'amit'. I didn't understand why it is happnes. See the below steps done. mysql> use amit; mysql> show tables; +----------------+
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9043
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.