2

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.

Kostas K.
  • 8,293
  • 2
  • 22
  • 28
  • 2
    Not sure I fully understand your question, but try `DCount("UniqCONCAT", "tblDataTable", "UniqCONCAT = '" & KONKAT & "'")`. – Kostas K. Dec 17 '21 at 13:34
  • Or don't bother with KONKAT variable if it is never referenced again. `DCount("*", "tblDataTable", "UniqCONCAT='" & Me.uniqConcat & "'")`. Is UniqCONCAT a field in table holding the calculated result of concatenating 3 fields? That is usually unnecessary and often very bad practice. – June7 Dec 17 '21 at 19:15
  • If these inputs have already initiated a new record, what do you want to happen if the DCount confirms this combination already exists? – June7 Dec 17 '21 at 19:22

0 Answers0