Solved

How to stop code after data is entered

Posted on 2006-06-19
3
151 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 50 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

695 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