Hi Zyus,
Use the Before_Update event procedure for the textbox in question. In the
sample code shown below, the name of the textbox for the loan amount is
"txtLoan", and the name of the textbox for the product is "txtProduct". The
bound fields are named "Loan" and "Product", respectively.
Option Compare Database
Option Explicit
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo ProcError
Dim strProductCode As String
Dim curLoan As Currency
strProductCode = Left$(Me.Product, 1)
curLoan = Me.loan
Select Case strProductCode
Case "A", "B"
If curLoan < 5000 Or curLoan > 50000 Then
MsgBox "The loan amount is not valid for this product." _
& vbCrLf & "Please enter an amount between $5,000 to
$50,000."
txtLoan.SetFocus
Cancel = True
End If
Case "C"
If curLoan < 20000 Or curLoan > 100000 Then
MsgBox "The loan amount is not valid for this product." _
& vbCrLf & "Please enter an amount between $20,000 to
$100,000."
txtLoan.SetFocus
Cancel = True
End If
Case Else
' Insert appropriate code here
End Select
ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, , _
"Error in Form_BeforeUpdate event procedure..."
Resume ExitProc
End Sub
If my answer has helped you, please answer yes to the question that reads
"Did this post answer the question?" at the bottom of the message thread.
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
:
Is it possible to put IIF function in a text box in form to validate data
entry.
Say Product A & Product B - Loan range between 5000 to 50,000
Product C - Loan range between 20,000 to 100,000
In the validation rule i write
=IIf([product] Like "A*" And Like "B*",[loan] Between 5000 And
50000,IIf([product] Like "C",[loan] Between 20000 And 100000,0))
Thanks