lookforsmt
Registered User.
- Local time
- Tomorrow, 00:32
- Joined
- Dec 26, 2011
- Messages
- 672
HI! all
I am trying to do validate a field on form and subform with a table field.
Below is my code i am not sure what i am doing wrong
any suggestions pls
I am trying to do validate a field on form and subform with a table field.
Below is my code i am not sure what i am doing wrong
Code:
Option Compare Database
Private Sub chqbrcd_AfterUpdate()
Me.creditAccount_ac.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub creditAccount_ac_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stlinkcriteria As String
Set rsc = Me.RecordsetClone
Dim a As String
Dim b As String
a = Me.creditAccount_ac.Value
' b = Left(a, 2)
' Debug.Print c
' If b <> "EN" Then
' Me.Undo
' MsgBox "EN is not the first character! Kindly check " & b
' End If
Set rsc = Nothing
stlinkcrieria = "[creditAccount_ac]" & "'" & SID & "'"
'Check tbl_Masterchqbrcd for duplicate barcode
If DCount("*", "[tbl_DailyData]", "[CreditAC] ='" & creditAccount_ac & "' and [duedate_ac] = " & SQLDate(dueDate)) = 0 Then
Me.Undo
MsgBox "Warning Cheque Barcode " _
& SID & " has already been Scanned, " _
& vbCr & vbCr & "Kindly check previous record and Re-scan correct Barcode,", vbInformation _
, "Duplicate Barcode Information"
End If
Set rsc = Nothing
End Sub
Function SQLDate(dt As Date) As String
On Error Resume Next
If IsDate(dt) Then SQLDate = Format(dt, "\#dd-mmm-yyyy#")
End Function
any suggestions pls