Solved

Command button

Posted on 2000-04-07
3
158 Views
Last Modified: 2010-05-02
If I accidentally press any command buttons on a form two or three times, the calculated quantities should not change.  how can I do this?
0
Comment
Question by:fuad2
  • 2
3 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2693628
after the user clicks it once, disable the button until you want to allow the user to click it again.

command1.enabled = false
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2693638
or create a public boolean variable called answered or something and use it like this


Option Explicit
Dim answered as Boolean


Private Sub Form_Load()
answered = FALSE

Private Sub Command1_Click()
If answered = FALSE Then
   'do some calculations
   answered = TRUE
Else
   Exit Sub
End Sub
0
 
LVL 2

Accepted Solution

by:
ndnet earned 30 total points
ID: 2695392
I can see where this would be useful. The first answer given is better, since the user doesn't think that the button is still active.

If you use the second method, be sure to make edits to each textbox (or, more accurately, variable involved in the calculation) allow the command button to come back to life.

You could combine the two techniques  into your program like this:

Option Explicit
Dim answered as Boolean

Private Sub Textbox1_Change()
If answered = TRUE then
   'Allow calculations again
   answered = FALSE
   Command1.enabled = TRUE
End If

Private Sub Command1_Click()
If answered = FALSE Then
   'Insert happy calculations
   answered = TRUE
   Command1.enabled = FALSE
Else If answered = true then
Else
   msgbox "error"
End If
Exit Sub



You'll have to add the code from textbox1_change to all fields that change the data used by your calculations.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 56
Excel Vlookup to move data back to source. 4 83
Paint/Redraw window while dragging 16 68
MS Date Picker 64 bit 32 bit issue 12 49
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

910 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

15 Experts available now in Live!

Get 1:1 Help Now