?
Solved

How to stop code after data is entered

Posted on 2006-06-19
3
Medium Priority
?
154 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

800 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