473,833 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating formula in access

4 New Member
Hello

I am student and trying to learn access.I am having problem in making a program can any one help me?

i wanted to make 2 tables in access and then create a link.First i am telling u what these tables contain then i will proceed.

(i have also tried this in excel but failed to do so).


table 1 (contains following items)

D T
3/4 0.35
1 0.69
2.3 0.59
2/3 0.76

table 2 (contains following items)
D W
3/4 =4.85*T(D-T)
1 =4.85*T(D-T)
2/3 =4.85*T(D-T)
2.3 =4.85*T(D-T)
i want to create link in these two tables such that when i am going to enter value of D it automatically calculate the value of W (the formula of W is written in table 2) by picking up the value of T from table 1 and then doing it.

now my first problem is that i dont know how to write formula in access.Is this the way, in which i should write formula in access???? as this is the way in which we used to write formula in excel.

And my second question is that should i have to create a querry for calculating value of W.If yes then which type of querry and how.

A little bit of help will also be greatly appreciated.

Thanks.
Jul 3 '06 #1
5 12199
comteck
179 New Member
I'm not quite understanding your formulas. However, the way to do this is simple. You create a form with 2 textboxes (name them textbox1 and textbox2), and a Command button (name it btnCalculate). Right Click on the Command Button, and click "Build Event". Choose "Code Builder", and the code window will open, with the following code:

Private Sub btnCalculate_Cl ick()

End Sub

You then put your fomula in betwwen the "Private" and "End". You also have to declare your variables (using Dim). So, it should look like this when you are done.

Private Sub btnCalculate_Cl ick()
Dim D, W As Integer
D = Me.Textbox1
W = D * 2
Me.Textbox2 = W
End Sub

All I have here is "W=D*2" for a formula. You replace it with whatever formula you want. Remember, you have to declare all variables.

Good Luck.
Jul 3 '06 #2
nedian
4 New Member
Thanks for guiding me, but i am still encountering some problem.I will be really greatful if u guide me more.

what u have told me i have tried that but it is not completed without errors.let me tell u what i have done so far then i will tell u where i am having problem.

First of all i have created a table in which i have taken 3 entities.

1) Id ( primary key).(i have taken this enitity because a primary key is must for any table)
2) D
3) T

The next thing which i have done is: i have created a form by using design view.

u told me that
"create a form by using two textboxes( name them textbox1 and textbox2) and a Command button (name it btnCalculate). Right Click on the Command Button, and click "Build Event". Choose "Code Builder", and the code window will open, with the following code:"

Now my question is that when i created the first textbox, by clicking on the textbox button and then clicking on the form there appereared two boxes. the one with a transparent box inside which is written textbox0( i then changed the name, and name it textbox1.) and the other box is a white box inside which it is written "unbound" . In the same manner i have created two other textboxes and named it textbox2 and textbox3.

I have also created a Command button as per your instructions and when the code window is opened. i finished writing the code which appeared as follows.
Private Sub btnCalculate_cl ick( )
Dim D,Dim T,W As Integer
D = Me.Textbox1
T = Me.Textbox2
W = 4.85 * T(D - T)
Me.Textbox3 = W
End Sub

when i runned that it is showing me error on second line

Dim D,Dim T,W As Integer

and this line appears in red.

Now what should i do.i have declared the variables D and T as u told me.but it is not accepting the variable T, i don't know why.

I am simply trying to make a program in which there are two variables D and T and the values of D and T are saved in a table. and this programs helps me to calculate the value of W (formula of W=4.85*T(D-T) ) whenever i give the value of D without giving the value of T with it.

i think "form" is not suitable for my program because in form when i have to calculate the value of W i have to give both the values of D and T and this is the thing which i don't want to do.

I am in dire need of further guidance.

Thanks
Jul 5 '06 #3
comteck
179 New Member
First of all, I'm not sure how familiar you are with Access. You might want to go online and do some of the online tutorials (there are many free ones). Here is one: http://www.functionx.com/vbaccess/.

But to get back to your problem. When you created your textbox, you said you got 2 textboxes (a transparent one, and a white box with the word "unbound". The transparent one is not actually a textbox. It is a label for the textbox that you created. You can click on just that label and delete it if you wish. It is the white box that must be renamed. You right click on it, and choose "Properties ". Then put the name into the "Name" field (which is the first field under the "All" tab).

As for your red message that comes up for:
Dim D, Dim T, W, as Integer

Remove the second "Dim" word. It should only read:
Dim D, T, W as Integer

If it still doesn't accept the variables, you might have to assign a value to them initially. To do this, after your "Dim" statement, add this code:
D=0
T=0

And lastly, you said you don't think form is
Good Luck.

comteck
Jul 5 '06 #4
comteck
179 New Member
First of all, I'm not sure how familiar you are with Access. You might want to go online and do some of the online tutorials (there are many free ones). Here is one: http://www.functionx.c om/vbaccess/.

But to get back to your problem. When you created your textbox, you said you got 2 textboxes (a transparent one, and a white box with the word "unbound". The transparent one is not actually a textbox. It is a label for the textbox that you created. You can click on just that label and delete it if you wish. It is the white box that must be renamed. You right click on it, and choose "Properties ". Then put the name into the "Name" field (which is the first field under the "All" tab).

As for your red message that comes up for:
Dim D, Dim T, W, as Integer

Remove the second "Dim" word. It should only read:
Dim D, T, W as Integer

If it still doesn't accept the variables, you might have to assign a value to them initially. To do this, after your "Dim" statement, add this code:
D=0
T=0

And lastly, you said you don't think form is suitable because you don't want to enter the values of D and T. First of all, a form is used to make it more user friendly. You can use a form with any table or query in your database. And, a form is the only place you can put the button. So, yes, a form will definitely work. Secondly, where is it you want to get your values from? If you want to get them from pull down menus, then you have to use combo boxes instead of text boxes. Then, the code will be basically the same, but you will have to set up 2 more tables, and source those tables to your combo boxes.

If you were looking to use the pull down menus, let me know and I'll try and walk you through it.


Good Luck.
comteck
Jul 5 '06 #5
nedian
4 New Member
Thanks for your help, i am now able to calculate the value of W and my half task is done.

But the problem is that when i opened the form it is showing me the value of D and T both by itself (as it is stored in the table from which i am taking the data).and it is not asking the user to enter the value of D.

but what i want to do is that:

i want myself to enter the value of D in the form and want the form to show me the corresponding value of T (which is stored in the table on which the "form" is based on ) and when it showed me the value of T on the textbox then i proceed my work, of calculating the value of W by clicking on the btnCalculate.

Thanks again.
Jul 6 '06 #6

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

Similar topics

1
2688
by: Dim | last post by:
Hi, need some help/idea... I have data table in Excel(about 30 columns) and it's getting too big (over 65K) so I need to move it to DB (MS Access is the choice) one of the columns (for example column1 in DataTable has a string (for example AAA, ABC or BCA, etc) and i also have lookup table in excel with formulas which contains a business rule for one of the columns (column35) on how to calculate: for example for AAA the calculation would...
7
2054
by: Helen | last post by:
vb .net 200 crystal reports Oracl Acces Hi, I have all selection formula results needed from the main crystal report, called in the vb form (Oracle db) I now need to build in the logic in the vb form selection formula to obtain results also from the subreport (Access db) The two databases are totally unrelated
0
1821
by: RJN | last post by:
Hi I have a main report and a sub report. I have a formula field on the main report and one on the sub report. I want the formula in the subreport to be evaluated after the formula in the main report. The sub report is called in the report header of the main report and the formula fields are in the details section of the reports. Main report looks something like this.
0
1622
by: RJN | last post by:
Hi Sorry for posting this message again. I have a main report and a sub report. I have a formula field on the main report and one on the sub report. I want the formula in the subreport to be evaluated after the formula in the main report. The sub report is called in the report header of the main report and the formula fields are in the details section of the reports. Main report looks something like this.
0
2207
by: rjn | last post by:
Hi I have a main report in which I have inserted a sub report. I have a formula field on the main report and one on the sub report. I want the formula in the subreport to be evaluated after the formula in the main report. The sub report is called in the report header of the main report and the formula fields are in the details section of the reports. Main report looks something like this. Report Header
1
5486
by: nedian | last post by:
Hello I am student and trying to learn access.I am having problem in making a program can any one help me? i wanted to make 2 tables in access and then create a link.First i am telling u what these tables contain then i will proceed. (i have also tried this in excel but failed to do so). table 1 (contains following items) table 2 (contains following items)
3
4250
by: skiddle | last post by:
I've got an Excel formula that calculates the total business hours that a help desk ticket is open. As one would expect, it factors out holidays and non-work hours. What would be the corresponding formula in Access? =IF(AND(INT(StartDT)=INT(EndDt),NOT(ISNA(MATCH(INT(StartDT),HolidayList,0)))),0,ABS(IF(INT(StartDT)=INT(EndDt),ROUND(24*(EndDt-StartDT),2), (24*(DayEnd-DayStart)* (MAX(NETWORKDAYS(StartDT+1,EndDt-1,HolidayList),0)+...
1
1478
by: DE529 | last post by:
Is there a way to override a formula in Access 2003? 90% of the time the formula fits with what I am needing, however there are times when I need to put in a different amount than what the formula is giving me. Thank you!
2
2938
by: welshkaiboy | last post by:
Due to the size of the data I have to manipulate I need to apply a excel formula in access which determines date of manufacture from a serial number 716001 so I use =VALUE(DATE(VALUE(MID(A1,3,1))+2000,1,1))+VALUE(MID(A1,4,3))-1 which gives 1/1/2006 How can I get this formula to work in access I know that the field name replaces the cell reference. I am just finding my feet in access and struggling to get this to work. I don’t really want...
0
10782
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10500
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
10213
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
9323
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...
1
7753
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
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
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5789
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3078
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.