Ellis Ellis
Ellis Ellis

Reputation: 33

DCount using a Dim reference in Access VBA

Really struggling to get my reference to register in the search? I'm trying to create a check to see if the record is already in my table?

Private Sub Command10_Click()

Me.UniqCONCAT = (Me.CQRWeekNumber) & (Me.UserNametxt) & (Me.CQRSite)

Dim KONKAT As String
KONKAT = Me.UniqCONCAT

Dim CountNumber As Integer
CountNumber = DCount("UniqCONCAT", "tblDataTable", "UniqCONCAT = 'KONKAT'")

If CountNumber > 0 Then
   MsgBox "This record is already in the system"
   Exit Sub
Else
   MsgBox "Go Ahead"

End Sub

It works if I use a static text reference. I need to search for my concatenated data (KONKAT)

Firstly I populate a field on the form with the concatenation (and that works)

Your advice and patience is appreciated in advance.

Upvotes: 2

Views: 319

Answers (0)

Related Questions