Solved

How to stop code after data is entered

Posted on 2006-06-19
3
145 Views
Last Modified: 2010-05-03
I have the code below. It does what I need it to do, but I don't want to allow the user to click twice as it would change the results. I need a sort of a run once thing as long as that window is open.
How can I get the code to stop and not allow it to run if results are already in the textticketfield(29)

Private Sub cmdGift_Click()

 txtticketfields(29).Text = FormatCurrency(CCur(txtcustomerfields(17).Text) - CCur(txtticketfields(20))) + CCur(txtticketfields(19))
   
  txtcustomerfields(17).Text = CCur(txtticketfields(29))

End Sub
0
Comment
Question by:mindserve
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
rettiseert earned 50 total points
Comment Utility
Private Sub cmdGift_Click()

static alreadyRun as boolean

if not alreadyRun then
 txtticketfields(29).Text = FormatCurrency(CCur(txtcustomerfields(17).Text) - CCur(txtticketfields(20))) + CCur(txtticketfields(19))
   
  txtcustomerfields(17).Text = CCur(txtticketfields(29))

alreadyRun =true

end if

End Sub
0
 
LVL 1

Author Comment

by:mindserve
Comment Utility
Thanks for the help,
Just one question though, if I wanted to reverse it say on the change of a tab screen SSTab1=0 how would I undo this without having to close down the screen.
0
 
LVL 13

Expert Comment

by:rettiseert
Comment Utility
I guess you'll need a global variable:
---------------------------------------------------

private alreadyRun as boolean

Private Sub ResetAlreadyRun()
    alreadyRun = false
End Sub

Private Sub cmdGift_Click()
   if not alreadyRun then
      txtticketfields(29).Text = FormatCurrency(CCur(txtcustomerfields(17).Text) - CCur(txtticketfields(20))) + CCur(txtticketfields(19))
      txtcustomerfields(17).Text = CCur(txtticketfields(29))
      alreadyRun =true
   end if
End Sub
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now