Kamis, 15 Agustus 2013

[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

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar