Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA for Access - syntax issues

Status
Not open for further replies.

canam1

Programmer
Apr 3, 2007
1
US
Could someone please tell me what I'm doing wrong here?

This is an event procedure in Access. It doesn't matter what I type in the NetWeight field, the box always pops up whether the number is below or above 125000. I would like the ability to limit the amount to 125000 or less with the ability to type in an over ride password for amounts over 125000. I haven't figured out how to do the password part either. As you can see I am a complete novice at this.

Private Sub NetWeight_Exit(Cancel As Integer)

Dim NetWeight As Integer
Dim strPrompt2 As String
Dim strTitle2 As String
Dim strResponse2 As String

strTitle2 = "PassWord Override"
strPrompt2 = "Please enter the override password"
strResponse2 = InputBox$(strPrompt2, strTitle)

If NetWeight <= 125000 Then
Exit Sub
Else
If NetWeight > 125000 Then
strResponse2 = InputBox$(strPrompt2, strTitle2)

End If
End If

End Sub


Thanks,
JMCK
 
A starting point:
Private Sub NetWeight_Exit(Cancel As Integer)
Dim strPrompt2 As String
Dim strTitle2 As String
Dim strResponse2 As String

strTitle2 = "PassWord Override"
strPrompt2 = "Please enter the override password"
strResponse2 = InputBox$(strPrompt2, strTitle)

If Val(Me![NetWeight]) <= 125000 Then
Exit Sub
End If
strResponse2 = InputBox$(strPrompt2, strTitle2)
If strResponse2 <> "good reply" Then
Cancel = True
End If
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top