Compatible Support Forums: Access 2000

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Access 2000

#1 User is offline   bytemangler 

  • member
  • Group: Members
  • Posts: 114
  • Joined: 27-February 01

Posted 17 October 2004 - 08:02 PM

Hello all,
Well, I have a project I need to do in Access2000 (why access 2000 and not 2003? corporate have not upg yet). I will be heading to Barnes and Noble later today but here's what I have. I just created a form with rows setup. RowA,B,C, and Total. User will enter numeric data in A,B,C. What I like to to do is on LostFocus (when a user tab away from either a,B, or C) the Total row will automatically sum up the current total. If this require VB script can you give sample please...thanks

0

#2 User is offline   felix 

  • addict
  • Group: Members
  • Posts: 691
  • Joined: 28-October 99

Posted 20 October 2004 - 03:26 AM

I would simply do this:

Set each txt box to be numeric only through the properties. Then do the following code where text0/1/2 are the boxes that accept user input and text3 is the total box.


Option Compare Database
Option Explicit

Private Sub Text0_afterupdate()
Me.Text3 = Me.Text0 + Me.Text1 + Me.Text2
End Sub

Private Sub Text1_afterupdate()
Me.Text3 = Me.Text0 + Me.Text1 + Me.Text2
End Sub

Private Sub Text2_afterupdate()
Me.Text3 = Me.Text0 + Me.Text1 + Me.Text2
End Sub


This way, not matter which field has a value or no value it will add it up.
You can then add error trapping "IF" statements and msgbox's to alert the user to their stupidity. If you've set the boxes to numeric only, they will only accept numbers. It depends on what range of numbers you are expecting. With no error trapping, the boxes will accept any number, small or large.
0

#3 User is offline   AndyFair 

  • old hand
  • Group: Members
  • Posts: 748
  • Joined: 21-May 01

Posted 21 October 2004 - 03:11 PM


0

#4 User is offline   felix 

  • addict
  • Group: Members
  • Posts: 691
  • Joined: 28-October 99

Posted 21 October 2004 - 04:16 PM

AndyFair,
You are correct in so much as that when a new record in a table is created the values in a numeric field are set to "0" however on a form where the text field is unbound, the fields will remain NULL unless a value is entered by the user or the default value is set in the field properties.

If the field is bound to a field in the table, obviously it will display the value from the table, which unless changed, defaults to "0".

F

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users