Access 2010. Windows 7
I am trying to test to see if there is already a record with a particular tagname that is enterted on Forms!FrmIOClone!TagName.
If there is no record add that record, but if there is 1 or more record with that tagname then do not add that record.
The code below return 4,053 records when in fact it should be 0.
The code MsgBox DCount("TagName", "tblio", Forms!FrmIOClone!TagName) return 4053 records, when it should return only 0.
When I entered a unique value on Forms!FrmIOClone!TagName and click OK the statement below is not 0 so it branches
to else
If DCount("tblIO.TagName", "tblio", Me.TagName) = 0 Then
/////////////////////////////////////////////////////////////////////////////
Private Sub OKButton_Click()
MsgBox DCount("TagName", "tblio", Forms!FrmIOClone!TagName) <<<---- It gave the total number of records (4053) in the table. It suppose to have 0.
If DCount("tblIO.TagName", "tblio", Me.TagName) = 0 Then
recIO.AddNew ' No. New or Clone mode
Else
MsgBox "This tagname is already in table TblIO. Only one tagname is allowed in the database.", vbCritical, "A tagname must be unique."
Exit Sub
End If
End Sub