Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2006, 09:49 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need answer by this weekend if possible

I need to write a code or macro that can do the following: Let me know if there is some example listed somewhere in some book, online, etc. Thanks is advanced for help.

Example:

If the age is 10 and the height is 5'5" what is the weight
If the age is 10 and the height is 6'0" what is the weight
If the age is 10 and height is 6'5" what is the weight

and on and on...........etc.

also

If the age is 11 and the height is 5'5" what is is the weight
If the age is 12 and the height is 5'5" what is the weight

This will range from age 10 thru 65 years old
and the height will range from 3 feet to 8 feet tall

Please help - very desparate.

If

Michele Haywood
__________________
Michele Haywood
 
Old October 27th, 2006, 09:52 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Do you have a formula to calculate the weight?

Mike
EchoVue.com
 
Old October 27th, 2006, 10:00 AM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could Google "age weight height" or even Body Mass Index (BMI). Doing a quick search I didn't see anything that related age with height & weight. I'm not sure that there is such a relation, but you might find differently.

-Phil-
 
Old October 27th, 2006, 11:34 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for not being clear so let me reword my question. I need a look up box (or something). first of all there is no formula and I only used height, age and weight as an example. Below is what I am really trying to achieve and I need to do it in Access.

Here we go: If Sch2 is selected and Diam 3" is selected I need for the result to display as 1.93 as shown below. Keep in mind that the next selection could be if Sch1 is selected and Diam 4" is selected the result should display as 4.43. I would like for this to some type of a lookup.

Schedu Diam1 Diam2 Diam3 Diam4 Diam5
    1" 2" 3" 4" 5"
Sch1 1.67 2.33 3.42 4.43 4.76
Sch2 1.76 1.88 1.93 5.25 5.67
Sch3 1.88 1.93 2.15 6.77 6.89
Sch4 1.9 2.2 2.45 3.99 7.33


Michele Haywood
 
Old November 22nd, 2006, 12:42 AM
Authorized User
 
Join Date: Nov 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

store it in a table and run a query on it
 
Old November 22nd, 2006, 05:57 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

Michelle,

gigaboy is, in essence, right, even though he hasnt really solved your problem.

My suggestion would be to set up a function for this. It takes two inputs (Schedule and Diameter) and gives one output (the result).

You will need to set up a table with your values, I would suggest just entering your data in a basic way, ie:

3 fields:

tblValues:
ScheduleType (1,2,3,4 etc)
DiameterType (1,2,3,4,5 etc)
Value (1.67, 2.33, 3.42 etc)

Doing it this way means you arent forced to come up with values for combinations that dont exist and also means you do not have to redesign your table if "Diameter 6" or "Schedule 5" comes along all of a sudden. You just simply add the new data.

You then want to do something along the lines of the following in a new module:

================================================== ====
public function pfunGetValue(lngSchedule as long, lngDiameter as long) as long

dim rst as recordset
dim strSQL as string

strsql = "Select Value from tblValues where Schedule = " & lngSchedule & _
         " AND Diameter = " & lngDiameter
set rst = currentdb.openrecordset(strsql)

pfunGetValue = rst!Value

rst.close

End function
================================================== ====

You might want to use something like:

pfunGetValue = nz(rst!Value,-999) as a not found identifier, instead though.

You can now simply use the function in your database, gives you a more dynamic way to use the data, on reports, in queries, etc

Use it like...
pfunGetValue(1,1) and should return 1.67 from your example.

Hope it helps.

Lee





Similar Threads
Thread Thread Starter Forum Replies Last Post
DateDiff excluding weekend days ghall202 Access VBA 1 March 3rd, 2008 09:48 AM
Try this, answer me surendran PHP How-To 1 November 14th, 2006 07:09 AM
Need help by this weekend Help-Help-Help Michele_Haywood Access VBA 0 October 27th, 2006 11:37 AM
Please answer canasdaq XML 3 April 19th, 2006 09:04 AM
i want answer titto_oo7 C# 7 February 9th, 2006 03:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.