Solved

How to stop code after data is entered

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Contents of a Directory In Access VBA 5 89
vb6 connector to SQL Server 2 42
SLMGR Switches Are Not Working On KMS Host 3 146
Passing a Text Box name to a Sub 6 102
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 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