I have tblWood, with a field txtWoodIDcode with entry's that identify a piece of wood.
For example:
txtWoodIDcode
Ash07:001
Ash07:002
Ash07:003
Ash07:004
Elm06:001
Elm06:002
Maple05:001
Maple05:002
Maple05:003
& so forth...
I have a form with a combo box that I select the first part of the string (the species of wood), the second part (the 2 digit year) is then concatenated onto this from a date function, and then a ":" is added.
So, I now have the substring "Maple07:" At this point it works fine. The problem is when I do a count for all of one species - in this case Maple. I need this to get the next number in the sequence for that species to append to the string for the full ID code. I am trying to do this using a DCount.
For some reason, this does not seem to find matches for the substring - but when I do the same search for the number "07", I get a match for all the records in the field.
The code is:
Private Sub cboSpeciesSelect_Click()
Dim species As String
Dim seq As Integer
species = Me.cboSpeciesSelect.Value & Right(DatePart("yyyy", Date), 2) & ":"
MsgBox (species)
seq = DCount("[txtWoodIDcode]", "tblWood", species)
species = species & seq
Me.SpeciesSelected.Value = species
End Sub
Am I missing something here? Everything I see indicates that DCount will work with strings - but apparently it may not work with substrings...
For example:
txtWoodIDcode
Ash07:001
Ash07:002
Ash07:003
Ash07:004
Elm06:001
Elm06:002
Maple05:001
Maple05:002
Maple05:003
& so forth...
I have a form with a combo box that I select the first part of the string (the species of wood), the second part (the 2 digit year) is then concatenated onto this from a date function, and then a ":" is added.
So, I now have the substring "Maple07:" At this point it works fine. The problem is when I do a count for all of one species - in this case Maple. I need this to get the next number in the sequence for that species to append to the string for the full ID code. I am trying to do this using a DCount.
For some reason, this does not seem to find matches for the substring - but when I do the same search for the number "07", I get a match for all the records in the field.
The code is:
Private Sub cboSpeciesSelect_Click()
Dim species As String
Dim seq As Integer
species = Me.cboSpeciesSelect.Value & Right(DatePart("yyyy", Date), 2) & ":"
MsgBox (species)
seq = DCount("[txtWoodIDcode]", "tblWood", species)
species = species & seq
Me.SpeciesSelected.Value = species
End Sub
Am I missing something here? Everything I see indicates that DCount will work with strings - but apparently it may not work with substrings...