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

Pull info from two tables and and a query

158 100+
I've got two tables tblPatient and tblIV. I have the PatientWeight in tblPatient, PatientAge in qryCalcPatientAge, 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 1664
PianoMan64
374 Expert 256MB
I've got two tables tblPatient and tblIV. I have the PatientWeight in tblPatient, PatientAge in qryCalcPatientAge, 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 100+
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 Expert 256MB
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.Gender, tblPatient.[WeightKG], tblIV.Trauma, qryFindAge.PatientAge,

(If (tblIV.Trauma = true) THEN INSERT INTO tblIV.IJEE (tblPatient.Weight * qryFindAge.PatientAge)) END IF

FROM (tblPatient INNER JOIN tblIV ON tblPatient.PatientID=tblIV.PatientID)
INNER JOIN qryFindAge ON tblPatient.PatientID=qryFindAge.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,556 Expert Mod 16PB
...(tblIV.Trauma 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,556 Expert Mod 16PB
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
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...
2
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...
5
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...
4
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...
5
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...
4
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...
6
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...
3
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.