Message Box

kcolbert01

Registered User.
Local time
Today, 12:43
Joined
Jan 13, 2003
Messages
36
I have a field called Totals that calculates the dollar amount from six other fields. I would like a message box to appear when the Totals field exceeds $1.00. I would like the meassage to say - "The TOTAL cannot exceed $1.00 - please adjust" and then have the curser go to the first of the six fields that is being added (that first field is called "6A".) So here is my code:

If Me!Totals > 1 Then
MsgBox "The TOTALS box cannot exceed $1.00 - please adjust", vbOKOnly, "TOTALS error!"
DoCmd.GoToControl "6A"


This code gives me the error: Invalid outside procedure.

I had it working and then I did something to mess it all up - I hate when that happens. Anyhow any insight would be much appreciated as I have to have this up and running by today.
 
Try:

If Me!Totals > 1 Then
MsgBox "The TOTALS box cannot exceed $1.00 - please adjust", vbOKOnly, "TOTALS error!"
Me.6A.SetFocus
Else
End if
 
Thanks but that didn't work - the Me.6A.SetFocus turns red and I still get the Invalid Outside Procedure message.

Any other ideas - I'm ready to toss this thing out the window :)
 
Copy of Databae

Here is a copy of my database. This is to enter the results of an employee survey. Keep in mind that I cannot change the setup because it is being evaluated by a third party and this is they way the wanted to see the results.

Thanks for your help!
 
I tried to post my database but I get a message that the file is too big which is puzzling to me because it only consists of one table with about 20 fields and a form with 22 records. I'm confused.

Any ideas? I'm sure there is a simple solution but its the most easiest solutions that I have the harder time with!
 
Are you zipping the file?

If so, do a compact on the database then rezip it.
 
You need to use some type of naming convention with your objects.
The text box and the name of the control source were both 6A and you
were confusing Access. Rename the text box to something like tb6A.

You need to be testing the totals in the forms BeforeUpdate event and
cancel the event if the total exceeds $1. Testing the forms AfterUpdate
event is too late for the user will already be on another record.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me!Totals > 1 Then
        MsgBox "The TOTALS box cannot exceed $1.00 - please adjust", vbOKOnly, "TOTALS error!"
        Me.[COLOR=blue]tb6A[/COLOR].SetFocus
        Cancel = True
    Else
        'do nothing
    End If
End Sub
Also, you have an orphaned End Sub at the top of your forms module. That is causing the Invalid Outside Procedure error.

You also have a P above the Command134_Click() that is causing another error.

I highly suggest that you compile you db before proceeding further. From inside the module, click the menu bar option Debug and click the option Compile and Save All Modules to check for any other errors in your db.

HTH
 
Last edited:
that is the most annoying db I have ever seen to debug! I kept locking up and the only way I could get out was ctrl-alt-del. Oh well.
 
OK - It's truly been one of those days. I have figured out the problem. It was never the original code it was something else. I had accidentally typed a "P" after an End Sub.

Whatever....I feel really relieved but very stupid at the same time - I'm going to the cafeteria for a brownie.

Thanks to everyone who took time out to read my post and help me out!
 

Users who are viewing this thread

Back
Top Bottom