Is your Public sub in a module or did you declare it in the form's
module?
Bob Peterson
-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of saigonf7q5
Sent: Thursday, August 15, 2013 2:36 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Referencing form?
Hello
I have the procedures as shown below. If I enter the argument without
the "Form_" which is like this "frmPshowData". It will generate a
"variable not defined" error.
When is it necessary to include the "Form_" and when it's not? e.g.
Form_frmPShowData, frmPShowData.
Another question that I have is, when a user left a require field blank,
in this case, a date. How do I keep the user from closing or exit out
the form without entering the correct data?
Thank you
Phucon
Private Sub Form_BeforeUpdate(Cancel As Integer)
Call ValidateData(Form_frmPShowData) End Sub
Public Sub ValidateData(Frm As Form)
On Error GoTo ErrorHandler
Select Case txtVData
Case "Yes"
Frm!txtVDate.Enabled = True
If Frm!txtVDate & "" = "" Then
MsgBox "Please enter a date.", vbExclamation,
"Invalid data"
Frm!txtVDate.SetFocus
End If
Case "No"
Frm!txtVDate.Enabled = False
Case Else
MsgBox "Enter ""Yes"" or ""No"" only", vbExclamation,
"Invalid Data"
End Select
ExitProcedure:
On Error Resume Next
Exit Sub
ErrorHandler:
MsgBox Err.Number & vbCrLf & Err.Description
Resume ExitProcedure
Resume
End Sub
------------------------------------
Yahoo! Groups Links
| Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar