Event Procedures - can't get them to work.

Joined
Apr 12, 2007
Messages
3
Reaction score
0
I am new to this site and to the forums, so please bear with me. I'm in an Access class with a terrible teacher and I have an assignment due Monday that I am completely lost on (I am also in a bit of a jam time-wise, so forgive me if this is in the wrong place).

The book says, "For a BonusQuota field value of 40, the Salary field value must be less than or equal to $30,000. If the Salary field value is invalid, display an appropriate message, cancel the event, undo the change, and move the focus to the Salary field."

I copied an example from the book (not the greatest idea, I know) and just tried to adjust it the best that I could. This is what I've come up with - forgive me if it's a mess.


Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim BonusQuota As Integer
Dim Salary As Currency
Select Case BonusQuota
Case "40"
If Salary > 30000 Then
DoCmd.CancelEvent
MsgBox "Salary must be less than or equal to 30,000"
Me.Undo
Salary.SetFocus
End If
End Select
End Sub


The teacher said that putting "Case "40" " implies that the BonusQuoat field is a text field, which is not, which confuses the program. So do I just avoid defining it as an integer, or is there something I'm supposed to use instead of quotations? Also, what else is wrong with this coding? I'm sure there is tons to fix but I have no idea what to do at this point. Any help would be appreciated! Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top