![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
On Aug 12, 1:36*am, Lanka Danweem <m... (AT) lankadanweempituwa (DOT) com> wrote: On Aug 11, 11:15*pm, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com wrote: On Aug 11, 2:05*am, Lanka Danweem <m... (AT) lankadanweempituwa (DOT) com> wrote: How to calculate form field Please any body know how to design a form with calculation on a field. How can I format the table field to get result of form field. Acturaly what I want is , when I ender numeric data to form field e..g I want to sum 5 data (125.50+200+100+45+75) for one field without calculate separately Are there any format to enter these as excel cell to get result *of 545.50?. Like this = 125.50+200+100+45+75) You can create a text box on a form. *If you open the property sheet up for the text box and give it a name of Sumit by pressing on the Other tab. *Then click on the Data tab and select ControlSource and enter: * =125.50+200+100+45+75 If you have field names * =YourFieldName1+YourFieldName2+YourFieldName3... You can now refer to it in code. * msgbox "Sum is " & Me.Sumit Thank, yes I'm doing it same. but I thought it may can do like MS excel.- Hide quoted text - - Show quoted text - To different products; *You could try this. *Create a 2 text boxes; Text0 and Text1. *In the controlsource of Text0 enter * =Eval([Text1]) Now in Text1 you can enter 1 + 2 + 3 and the result will show up in the other text box.- Hide quoted text - - Show quoted text - |
#12
| |||
| |||
|
|
On 12/08/2011 07:36:11, Lanka Danweem wrote: On Aug 11, 11:15*pm, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com wrote: On Aug 11, 2:05*am, Lanka Danweem <m... (AT) lankadanweempituwa (DOT) com> wrote: How to calculate form field Please any body know how to design a form with calculation on a field. How can I format the table field to get result of form field. Acturaly what I want is , when I ender numeric data to form field e.g I want to sum 5 data (125.50+200+100+45+75) for one field without calculate separately Are there any format to enter these as excel cell to get result *of 545.50?. Like this = 125.50+200+100+45+75) You can create a text box on a form. *If you open the property sheet up for the text box and give it a name of Sumit by pressing on the Other tab. *Then click on the Data tab and select ControlSource and enter: * =125.50+200+100+45+75 If you have field names * =YourFieldName1+YourFieldName2+YourFieldName3... You can now refer to it in code. * msgbox "Sum is " & Me.Sumit Thank, yes I'm doing it same. but I thought it may can do like MS excel. You could try this bit of code in an AfterUpdate of a unbound field called Text0 Private Sub Text0_AfterUpdate() * * Dim Stg As String, Letter As String * * Dim Tot As Single * * Dim i As Integer, j As Integer * * If Left(Text0, 1) <> "=" Then Exit Sub * * Stg = Right(Text0, Len(Text0) - 1) * * * * *' Lose the "=" * * For i = 1 To Len(Stg) * * * * Letter = Mid(Stg, i, 1) * * * * If Letter <> "0" _ * * * * And Letter <> "1" _ * * * * And Letter <> "2" _ * * * * And Letter <> "3" _ * * * * And Letter <> "4" _ * * * * And Letter <> "5" _ * * * * And Letter <> "6" _ * * * * And Letter <> "7" _ * * * * And Letter <> "8" _ * * * * And Letter <> "9" _ * * * * And Letter <> "." _ * * * * And Letter <> "+" Then * * * * * * MsgBox "This is not a simple sum", vbInformation * * * * * * Exit Sub * * * * End If * * Next i * * i = 0 NextFigure: * * i = InStr(i + 1, Stg, "+") * * * * * *' First "+" * * If i = 0 Then * * * * * * * * * * * ' no "+" single figure * * * * Tot = Tot + CSng(Mid(Stg, j + 1, Len(Stg) - j)) * * * * GoTo PrintIt * * Else * * * * Tot = Tot + CSng(Mid(Stg, j + 1, i - j - 1)) * * End If * * j = i * * GoTo NextFigure PrintIt: * * Text0 = Tot End Sub Phil- Hide quoted text - - Show quoted text - |
#13
| |||
| |||
|
|
Thank, yes I'm doing it same. but I thought it may can do like MS excel. You could try this bit of code in an AfterUpdate of a unbound field calle d Text0 Private Sub Text0_AfterUpdate() * * Dim Stg As String, Letter As String * * Dim Tot As Single * * Dim i As Integer, j As Integer * * If Left(Text0, 1) <> "=" Then Exit Sub * * Stg = Right(Text0, Len(Text0) - 1) * * * * *' Lose th e "=" * * For i = 1 To Len(Stg) * * * * Letter = Mid(Stg, i, 1) * * * * If Letter <> "0" _ * * * * And Letter <> "1" _ * * * * And Letter <> "2" _ * * * * And Letter <> "3" _ * * * * And Letter <> "4" _ * * * * And Letter <> "5" _ * * * * And Letter <> "6" _ * * * * And Letter <> "7" _ * * * * And Letter <> "8" _ * * * * And Letter <> "9" _ * * * * And Letter <> "." _ * * * * And Letter <> "+" Then * * * * * * MsgBox "This is not a simple sum", vbInformation * * * * * * Exit Sub * * * * End If * * Next i * * i = 0 NextFigure: * * i = InStr(i + 1, Stg, "+") * * * * * *' First "+" * * If i = 0 Then * * * * * * * * * * * ' no "+" single figure * * * * Tot = Tot + CSng(Mid(Stg, j + 1, Len(Stg) - j)) * * * * GoTo PrintIt * * Else * * * * Tot = Tot + CSng(Mid(Stg, j + 1, i - j - 1)) * * End If * * j = i * * GoTo NextFigure PrintIt: * * Text0 = Tot End Sub Phil- Hide quoted text - - Show quoted text - Thanks Pill ,,, This code not work for me. In what way dosen't it work.? Are you getting wrong results or does it crash |
#14
| |||
| |||
|
|
Yes this is work. But I cant bond Text0. |
![]() |
| Thread Tools | |
| Display Modes | |
| |