CharlieT302
Instructor
Hi,
I need help populating a field. The field is on a subform. The following code will populate my field by combining values from various other fields.
If IsNull(Me.Tracker_Painting_Number) Or Me.Tracker_Painting_Number.Value = "" Then
Me.Tracker_Painting_Number.Value = Me.[Artist Full Last 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)
else...
The above code works fine, however, I want to be able to check for existing records with the same values. As a test, I tried to display a message box indicating how many records have the same value. I get an error message when I run it. The criteria seems to be off even though "it appears" to be the same I used above.
Invalid Code:
************************************************************
MsgBox (DCount("Tracking_Painting_Number", "tbl_Tracker_Information_sub", "Me.Tracker_Painting_Number.Value = '" & Me.[Artist Full Last 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) & "'"))
************************************************************
My ultimate goal is to be able to count up items with the same base number and then add a value of 1 to the count to achieve a unique value.
Help is greatly appreciated.
I need help populating a field. The field is on a subform. The following code will populate my field by combining values from various other fields.
If IsNull(Me.Tracker_Painting_Number) Or Me.Tracker_Painting_Number.Value = "" Then
Me.Tracker_Painting_Number.Value = Me.[Artist Full Last 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)
else...
The above code works fine, however, I want to be able to check for existing records with the same values. As a test, I tried to display a message box indicating how many records have the same value. I get an error message when I run it. The criteria seems to be off even though "it appears" to be the same I used above.
Invalid Code:
************************************************************
MsgBox (DCount("Tracking_Painting_Number", "tbl_Tracker_Information_sub", "Me.Tracker_Painting_Number.Value = '" & Me.[Artist Full Last 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) & "'"))
************************************************************
My ultimate goal is to be able to count up items with the same base number and then add a value of 1 to the count to achieve a unique value.
Help is greatly appreciated.