lookforsmt
Registered User.
- Local time
- Tomorrow, 01:57
- Joined
- Dec 26, 2011
- Messages
- 672
Hi! I have DB with two tables:
tbl_linkchqbrcd
tbl_Masterchqbrcd
There is a form attached to tbl_linkchqbrcd
frm_MICR
When I scan chqbrcd it should look into table tbl_Masterchqbrcd if the record (chqbrcd) exist before accepting the scanned item, then accept else a pop up msg with the scanned details that it does not exist or duplicate barcode and field will be empty for scanning the next item
Below is the code currently works fine for DCount on tbl_linkchqbrcd but when I changed the table to another table tbl_Masterchqbrcd it does not work. Pls let me know what I am doing wrong or does it require any changes
Pls note this is taken from one of the forum and I have added it to my DB. I am completely new to vba codes
Code:
====
Option Compare Database
Private Sub chqbrcd_BeforeUpdate(Cancel As Integer)
Dim SID As String
Set rsc = Me.RecordsetClone
SID = Me.chqbrcd.value
stLinkCriteria = "[chqbrcd]=" & " ' " & SID & " ' "
'Check tbl_Masterchqbrcd for duplicate barcode
If DCount ("chqbrcd",tbl_Masterchqbrcd", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
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
I also have another code on the chqbrcd afterupdate
=================================
Private Sub chqbrcd_AfterUpdate()
If Len(Me.chqbrcd.Text) = 14 Then MICR_Code.SetFocus
Me.chqbrcdDate = Now()
Me.chqbrcdUpdateby = fOSUSERName
End Sub
There is also code KeyPress on chqbrcd
=========================
Private Sub chqbrcd_KeyPress(KeyAscii as Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
tbl_linkchqbrcd
tbl_Masterchqbrcd
There is a form attached to tbl_linkchqbrcd
frm_MICR
When I scan chqbrcd it should look into table tbl_Masterchqbrcd if the record (chqbrcd) exist before accepting the scanned item, then accept else a pop up msg with the scanned details that it does not exist or duplicate barcode and field will be empty for scanning the next item
Below is the code currently works fine for DCount on tbl_linkchqbrcd but when I changed the table to another table tbl_Masterchqbrcd it does not work. Pls let me know what I am doing wrong or does it require any changes
Pls note this is taken from one of the forum and I have added it to my DB. I am completely new to vba codes
Code:
====
Option Compare Database
Private Sub chqbrcd_BeforeUpdate(Cancel As Integer)
Dim SID As String
Set rsc = Me.RecordsetClone
SID = Me.chqbrcd.value
stLinkCriteria = "[chqbrcd]=" & " ' " & SID & " ' "
'Check tbl_Masterchqbrcd for duplicate barcode
If DCount ("chqbrcd",tbl_Masterchqbrcd", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
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
I also have another code on the chqbrcd afterupdate
=================================
Private Sub chqbrcd_AfterUpdate()
If Len(Me.chqbrcd.Text) = 14 Then MICR_Code.SetFocus
Me.chqbrcdDate = Now()
Me.chqbrcdUpdateby = fOSUSERName
End Sub
There is also code KeyPress on chqbrcd
=========================
Private Sub chqbrcd_KeyPress(KeyAscii as Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub