CharlieT302
Instructor
Hi,
The code below is designed to create a ID from various fields such as names and dates. This results in duplicates...which it is appropriate. However if a duplicate exists, the code assigns a number at the end to make it unique. It does this well.
However, when the code searches (it actually counts) for duplicates, I want it to search only the base code, regardless of the number placed at its end.
I would like to use a "wildcard" to accomplish this. How do I add a wildcard to the criteria?
Thanks
Sample Code:
************************************************************
Dim strNumber As String
Dim strCriteria As String
strNumber = Me.[Artist First Name] & Left(Me.[Artist Full Last Name], 1) & DatePart("m", Me.Date_Painting_Started) & DatePart("d", Me.Date_Painting_Started) & Format(DatePart("yyyy", Me.Date_Painting_Started), "yy") & Left(Me.Discipline, 2)
strCriteria = "[Tracker Painting Number] = '" & strNumber & "'"
If (DCount("*", "tbl_Tracker_Information_sub", strCriteria)) > 0 Then
Me.Tracker_Painting_Number.Value = Me.[Artist First Name] & Left(Me.[Artist Full Last Name], 1) & DatePart("m", Me.Date_Painting_Started) & DatePart("d", Me.Date_Painting_Started) & Format(DatePart("yyyy", Me.Date_Painting_Started), "yy") & Left(Me.Discipline, 2) & (DCount("*", "tbl_Tracker_Information_sub", strCriteria) + 1)
GoTo exit_sub
Else
Me.Tracker_Painting_Number.Value = Me.[Artist First Name] & Left(Me.[Artist Full Last Name], 1) & DatePart("m", Me.Date_Painting_Started) & DatePart("d", Me.Date_Painting_Started) & Format(DatePart("yyyy", Me.Date_Painting_Started), "yy") & Left(Me.Discipline, 2)
GoTo exit_sub
End If
The code below is designed to create a ID from various fields such as names and dates. This results in duplicates...which it is appropriate. However if a duplicate exists, the code assigns a number at the end to make it unique. It does this well.
However, when the code searches (it actually counts) for duplicates, I want it to search only the base code, regardless of the number placed at its end.
I would like to use a "wildcard" to accomplish this. How do I add a wildcard to the criteria?
Thanks
Sample Code:
************************************************************
Dim strNumber As String
Dim strCriteria As String
strNumber = Me.[Artist First Name] & Left(Me.[Artist Full Last Name], 1) & DatePart("m", Me.Date_Painting_Started) & DatePart("d", Me.Date_Painting_Started) & Format(DatePart("yyyy", Me.Date_Painting_Started), "yy") & Left(Me.Discipline, 2)
strCriteria = "[Tracker Painting Number] = '" & strNumber & "'"
If (DCount("*", "tbl_Tracker_Information_sub", strCriteria)) > 0 Then
Me.Tracker_Painting_Number.Value = Me.[Artist First Name] & Left(Me.[Artist Full Last Name], 1) & DatePart("m", Me.Date_Painting_Started) & DatePart("d", Me.Date_Painting_Started) & Format(DatePart("yyyy", Me.Date_Painting_Started), "yy") & Left(Me.Discipline, 2) & (DCount("*", "tbl_Tracker_Information_sub", strCriteria) + 1)
GoTo exit_sub
Else
Me.Tracker_Painting_Number.Value = Me.[Artist First Name] & Left(Me.[Artist Full Last Name], 1) & DatePart("m", Me.Date_Painting_Started) & DatePart("d", Me.Date_Painting_Started) & Format(DatePart("yyyy", Me.Date_Painting_Started), "yy") & Left(Me.Discipline, 2)
GoTo exit_sub
End If