D
dcc15 via AccessMonster.com
With much help and a lot of head scratching (learning), I have the following
code (working and tested) and to get this project completed (crunch time) I
need to add a text string (fixed) so the stored (as text) value will look
like : (TEXT) (YEAR) (MONTH) (NUMBER)= DMR-200711001, am hoping the prefix
(static text) can be added to the code somewhere (simple).
Thanks to all that have help in getting to this point.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim strWhere As String, strYrMo As String
Dim varResult As Variant
strYrMo = CDbl(Format(Date, "yyyymm"))
strWhere = "CStr([dmrincrnum]) Like """ & strYrMo & "*"""
varResult = DMax("[dmrincrnum]", "TBLdmr", strWhere)
If IsNull(varResult) Then
Me.dmrincrnum = strYrMo & "001"
Else
Me.dmrincrnum = Left(varResult, 6) & _
Format(Val(Right(varResult, 3)) + 1, "000")
End If
End Sub
code (working and tested) and to get this project completed (crunch time) I
need to add a text string (fixed) so the stored (as text) value will look
like : (TEXT) (YEAR) (MONTH) (NUMBER)= DMR-200711001, am hoping the prefix
(static text) can be added to the code somewhere (simple).
Thanks to all that have help in getting to this point.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim strWhere As String, strYrMo As String
Dim varResult As Variant
strYrMo = CDbl(Format(Date, "yyyymm"))
strWhere = "CStr([dmrincrnum]) Like """ & strYrMo & "*"""
varResult = DMax("[dmrincrnum]", "TBLdmr", strWhere)
If IsNull(varResult) Then
Me.dmrincrnum = strYrMo & "001"
Else
Me.dmrincrnum = Left(varResult, 6) & _
Format(Val(Right(varResult, 3)) + 1, "000")
End If
End Sub