[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to stop code after data is entered

Posted on 2006-06-19
3
Medium Priority
?
156 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
rettiseert earned 200 total points
ID: 16937853
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
ID: 16941975
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
ID: 16942657
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

656 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