Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 30th, 2005, 10:21 AM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems Using BeforeUpdate Event

Code:
Private Sub numChrgs_BeforeUpdate(Cancel As Integer)
    intSubscript = selectCustomer.ListIndex
    charge = charge - (Me.numChrgs.OldValue * m_900(intSubscript))
End Sub
this peice of code here pulls the amount to charge from the selected customer from the customer table and puts it in intSubscript

m_900 is a global set to currency

charge is supposed to update the textbox charge on the form to the updated price after a number has been entered into the numChrgs textbox


the problem is that unless the record has been saved, it erases the charges from the charges box only when the user enters something in a textbox and navigates to another checkbox of textbox to select or enter more info

any ideas so it wont erase charge when entering a new record without saving it first

Reply With Quote
  #2 (permalink)  
Old August 30th, 2005, 12:55 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This should be on the AfterUpdate event of numChrgs.

It also should be on the On Current event of the form.

It also should not be stored in the customer table at all. This is a calculated value and should not be stored as part of your regular data. It should be generated on your forms, reports or queries, but not stored.

HTH


mmcdonal
Reply With Quote
  #3 (permalink)  
Old August 30th, 2005, 01:22 PM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
Private Sub numChrgs_AfterUpdate()
    intSubscript = selectCustomer.ListIndex
    charge = charge + (Me.numChrgs.Value * m_900(intSubscript))
    'The record needs to be saved after the price is adjusted, if not then an incorrect price could be calculated.
    DoCmd.RunCommand acCmdSaveRecord
End Sub
this is what i have for the AfterUpdate

i need something for the BeforeUpdate so when I enter a number in the numChrgs textbox before saving the record it will update the price in the charge textbox and not erase it

if the record is already saved it will update the price as long as its not 0

if i change it from 0 to 1 i get no change

the price is pulled from another table, the check boxes work fine, i just have a If Then Else statement controlling them, but the textbox is giving me all kinds of problems cause its not going to be -1 or 0, it can be any number

Reply With Quote
  #4 (permalink)  
Old September 7th, 2005, 07:29 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry for the delay. Again, you should not have to store this number in your tables. Just generate it in forms or reports as needed. As long as the other numbers are there, you can generate any equation you need at runtime rather than storing static data.

mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Image Handler Click Event daniel.mihalcea C# 2008 aka C# 3.0 12 March 12th, 2010 06:29 AM
Event - Sender & Event args dash dev C# 2005 9 December 9th, 2007 07:24 AM
On Exit event Problems mohiddin52 Access VBA 3 October 9th, 2007 12:47 PM
Problems with Body onload event blaabil Javascript How-To 0 January 6th, 2006 06:45 AM



All times are GMT -4. The time now is 12:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.