Display message on form

G

Guest

I am trying to display a message when no loan number is entered on a Form.
There will be multiple people who will be using this form and the loan number
is my key field to pull information for reports. When I enter no loan
number I get the previous borrower displayed or if I'm starting with a blank
screen I get nothing and no message to the user to enter the loan number.
This is the code I am using when entering a loan number on the form. How can
I get "You must enter a valid loan number" to display when no loan number or
an invalid loan number is entered?


Private Sub Loan__Exit(Cancel As Integer)
Dim varBorrower As Variant
Dim varLoanNum As Variant
Dim strMsg As String

If IsNull(varLoanNum) Then
strMsg = "You Must Enter Valid Loan Number"

End If

varBorrower = DLookup("[Borrower]", "LoanNum Tbl", "[Loan Num] = [Loan#]")
If (Not IsNull(varBorrower)) Then Me![Borrower] = varBorrower


End Sub

Private Sub Loan__NotInList(NewData As String, Response As Integer)
Dim varLoanNum As Variant
Dim strMsg As String

If IsNull(varLoanNum) Then
strMsg = "You Must Enter Valid Loan Number"
End If

End Sub
 
V

Van T. Dinh

You set the message but I can't see the statement to display the message.

Check Access VB Help on MsgBox statement.
 
G

Guest

I am very green at writing code. I've used the sample database to try to
figure out how to make this work. I've managed to get the Dlookup to work,
but don't know exactly what I need to put into the code to display my
message. Any help you could give me would be appreciated.

Van T. Dinh said:
You set the message but I can't see the statement to display the message.

Check Access VB Help on MsgBox statement.

--
HTH
Van T. Dinh
MVP (Access)



GingerF said:
I am trying to display a message when no loan number is entered on a Form.
There will be multiple people who will be using this form and the loan
number
is my key field to pull information for reports. When I enter no loan
number I get the previous borrower displayed or if I'm starting with a
blank
screen I get nothing and no message to the user to enter the loan number.
This is the code I am using when entering a loan number on the form. How
can
I get "You must enter a valid loan number" to display when no loan number
or
an invalid loan number is entered?


Private Sub Loan__Exit(Cancel As Integer)
Dim varBorrower As Variant
Dim varLoanNum As Variant
Dim strMsg As String

If IsNull(varLoanNum) Then
strMsg = "You Must Enter Valid Loan Number"

End If

varBorrower = DLookup("[Borrower]", "LoanNum Tbl", "[Loan Num] =
[Loan#]")
If (Not IsNull(varBorrower)) Then Me![Borrower] = varBorrower


End Sub

Private Sub Loan__NotInList(NewData As String, Response As Integer)
Dim varLoanNum As Variant
Dim strMsg As String

If IsNull(varLoanNum) Then
strMsg = "You Must Enter Valid Loan Number"
End If

End Sub
 
D

Douglas J. Steele

You're setting a variable strMsg to hold what you want displayed. Once you
know what you want displayed, you need:

MsgBox strMsg

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


GingerF said:
I am very green at writing code. I've used the sample database to try to
figure out how to make this work. I've managed to get the Dlookup to
work,
but don't know exactly what I need to put into the code to display my
message. Any help you could give me would be appreciated.

Van T. Dinh said:
You set the message but I can't see the statement to display the message.

Check Access VB Help on MsgBox statement.

--
HTH
Van T. Dinh
MVP (Access)



GingerF said:
I am trying to display a message when no loan number is entered on a
Form.
There will be multiple people who will be using this form and the loan
number
is my key field to pull information for reports. When I enter no loan
number I get the previous borrower displayed or if I'm starting with a
blank
screen I get nothing and no message to the user to enter the loan
number.
This is the code I am using when entering a loan number on the form.
How
can
I get "You must enter a valid loan number" to display when no loan
number
or
an invalid loan number is entered?


Private Sub Loan__Exit(Cancel As Integer)
Dim varBorrower As Variant
Dim varLoanNum As Variant
Dim strMsg As String

If IsNull(varLoanNum) Then
strMsg = "You Must Enter Valid Loan Number"

End If

varBorrower = DLookup("[Borrower]", "LoanNum Tbl", "[Loan Num] =
[Loan#]")
If (Not IsNull(varBorrower)) Then Me![Borrower] = varBorrower


End Sub

Private Sub Loan__NotInList(NewData As String, Response As Integer)
Dim varLoanNum As Variant
Dim strMsg As String

If IsNull(varLoanNum) Then
strMsg = "You Must Enter Valid Loan Number"
End If

End Sub
 

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