Kamis, 15 Agustus 2013

RE: [MS_AccessPros] Referencing form?

 

Phucon,

Assuming the form you are validating is the current form I think you need to use:

Private Sub Form_BeforeUpdate(Cancel As Integer)
  Call ValidateData(Me)
End Sub

Duane Hookom MVP
MS Access

----------------------------------------
> To: MS_Access_Professionals@yahoogroups.com
> From: saigonf7q5@yahoo.com
> Date: Thu, 15 Aug 2013 18:36:03 +0000
> 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 (2)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar