Not saving a field on exit

123dstreet

Registered User.
Local time
Today, 06:03
Joined
Apr 14, 2010
Messages
122
Hi all! I'm having a minor problem.. in my form, I hit the "Update" button(code below) and it works fine, but if the taxes field is Null (there are no taxes) the Total does not save when I exit the form. It does, however, when there is taxes. I just don't want my users to have to hit the update button everytime they open the form as it may cause problems. I'm sure its something simple but any help would be appreciated! thanks so much


Code:
Private Sub updateb_Click()
On Error GoTo Err_updateb_Click
    
         
    [STotal] = [Order Details Subform].[Form]![SubTotal]
    [Total] = [Freight] + [STotal] + Nz([Taxes])
    [Balance] = [Total] - [Payment]
    
    DoCmd.RunCommand acCmdRefresh
Exit_updateb_Click:
    Exit Sub
Err_updateb_Click:
    MsgBox Err.Description
    Resume Exit_updateb_Click
    
End Sub
 
Does this help?

Code:
Private Sub updateb_Click()
On Error GoTo Err_updateb_Click
    
         
    [STotal] = [Order Details Subform].[Form]![SubTotal]
    [Total] = [Freight] + [STotal] + [B][COLOR=Red]Nz([Taxes],0)[/COLOR][/B]
    [Balance] = [Total] - [Payment]
    
    DoCmd.RunCommand acCmdRefresh
Exit_updateb_Click:
    Exit Sub
Err_updateb_Click:
    MsgBox Err.Description
    Resume Exit_updateb_Click
    
End Sub
 
Last edited:
Hi all! I'm having a minor problem.. in my form, I hit the "Update" button(code below) and it works fine, but if the taxes field is Null (there are no taxes) the Total does not save when I exit the form. It does, however, when there is taxes. I just don't want my users to have to hit the update button everytime they open the form as it may cause problems. I'm sure its something simple but any help would be appreciated! thanks so much


Code:
Private Sub updateb_Click()
On Error GoTo Err_updateb_Click
 
 
    [STotal] = [Order Details Subform].[Form]![SubTotal]
    [Total] = [Freight] + [STotal] + Nz([Taxes])
    [Balance] = [Total] - [Payment]
 
    DoCmd.RunCommand acCmdRefresh
Exit_updateb_Click:
    Exit Sub
Err_updateb_Click:
    MsgBox Err.Description
    Resume Exit_updateb_Click
 
End Sub

The Format of the Nz() Function is as follows:
Nz ( variant, [ value_if_null ] )
Try changing your statement to reflect this format and see what happens.
 
Hey thanks for all your help friends. Turns out I just had to put the Nz([Taxes,0]) in the form unload event and now it works like a mint. thanks again!
 

Users who are viewing this thread

Back
Top Bottom