Access 2000

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.

Windows Software 5498 This topic was started by ,


data/avatar/default/avatar15.webp

114 Posts
Location -
Joined 2001-02-27
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
 

Participate on our website and join the conversation

You have already an account on our website? Use the link below to login.
Login
Create a new user account. Registration is free and takes only a few seconds.
Register
This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


data/avatar/default/avatar33.webp

686 Posts
Location -
Joined 1999-10-28
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.

data/avatar/default/avatar05.webp

748 Posts
Location -
Joined 2001-05-21
Originally posted by Alec§taar:

Quote:NOTE - FELIX!!! "Shame on you man" - you didn't check to see if the field was blank/null!!!As far as I'm aware, if the field type is set to "number", the field values default to 0 not to NULL, so you shouldn't need check for NULL fields.
 
Rgds
AndyF

data/avatar/default/avatar33.webp

686 Posts
Location -
Joined 1999-10-28
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