Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

Form Calculations

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sean H - 21 Oct 2005 18:41 GMT
Hello,
Is there a way to calculate a form field from two other form fields in the
same form?  I would like the user to be able to enter a number in Field 1, a
percentage in Field 2, and then calculate Field 1 * Field 2 = Field 3.  I
tried to do this by changing the properties for Field 3 but I didn't get the
desired result.

Also, once Field 3 is calculated, I would like the form to automatically
skip over it so that the user does not accidentally write over the calculated
value.

Any help would be greatly appreciated.

Thanks,
Sean Heckathorne
BruceM - 21 Oct 2005 19:04 GMT
Are you talking about a Word form?  If so, you would do better to ask in a
Word group.  This group is for Access, a relational database program.

> Hello,
> Is there a way to calculate a form field from two other form fields in the
[quoted text clipped - 14 lines]
> Thanks,
> Sean Heckathorne
Adam Turner - 21 Oct 2005 19:41 GMT
>Hello,
>Is there a way to calculate a form field from two other form fields in the
[quoted text clipped - 11 lines]
>Thanks,
>Sean Heckathorne
Sean...
If you're refering to VBA, you access any field from any form within the same
document. Just make sure you're referencing the object correctly.

iNum = CInt(tNum.Text)
iPercent = CInt(tPercent.Text)
iPercent = iPercent * .01
iAnswer = iNum * iPercent

frm1.txtAnswer.Text = iAnswer
frm1.txtAnswer.Enabled = False

...my stab at it
Tom - 21 Oct 2005 22:05 GMT
First off when you create your form the table that contains your data must be
used in order to select the correct data fields.

1. Create your form with the two fields containing your data, "field1" and
"field2". Select the fields and place them on the form "form1".

2. Then place a blank "text box" from the controls list onto the form. On
the  properties field "controlsource"  of the "text box", select "Expression
Builder"  and then select "form1" if that is the name of your form. When you
select "form1" you will see the fields attached to form1. It should contain
"field1" and "field2".

3. Select "field1" and paste to the expression box, select "*" and then
select "field2". The experession will look like this "field1*field2". Once
you close the expression box the expression will look like this
"=field1*field2" in the "ControlSource" field.  Copy this expression to the
Events tab "Before Update" and "After Update" Properties fields.

4. In order to lock your text box so no one will modify it, go to
"properties" on the text box that contains your formula and then to the
"Data" tab and select the locked field "Yes"

Tom

> Hello,
> Is there a way to calculate a form field from two other form fields in the
[quoted text clipped - 11 lines]
> Thanks,
> Sean Heckathorne
Sean H - 24 Oct 2005 14:29 GMT
Thanks tome, that worked exactly as I wanted it to.  I'm having one more
problem though.  I'm testing out the formula, and "field 2" is a percentage.  
When I try to enter in a value like 16%, I type .16, but when I press enter,
the text field resets to 0.00%.  I tried setting the number of decimal places
to 2 or 3 or 4 but nothing seemed to work.  Thanks again.

-Sean Heckathorne

> First off when you create your form the table that contains your data must be
> used in order to select the correct data fields.
[quoted text clipped - 35 lines]
> > Thanks,
> > Sean Heckathorne
Tom - 26 Oct 2005 16:18 GMT
Hi H,

Make the following adjustments, and this should fix your problem.

"Table1', "Field2" must have the following properties adjusted.
 "Field size" = "single"
 "Format" = "Percent"
 "Decimal Places" = "Auto"
 "Default value" = "0"
 "Validation Rule" = "<1"

"Form1",  "field2" properties must be modified to display this input.
"Format" = "percentage"

Tom

> Thanks tome, that worked exactly as I wanted it to.  I'm having one more
> problem though.  I'm testing out the formula, and "field 2" is a percentage.  
[quoted text clipped - 43 lines]
> > > Thanks,
> > > Sean Heckathorne
Sean H - 26 Oct 2005 18:38 GMT
Perfect, thanks Tom.  My problem before was that I was just focusing on the
properties in the form but not on the properties in the table.  It never hit
me that since they're related they should also have related properties.

> Hi H,
>
[quoted text clipped - 59 lines]
> > > > Thanks,
> > > > Sean Heckathorne
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.