M
Marcelino Benitez via AccessMonster.com
I running a work order application. I have a counter field that contains a
letter, julian date and a counter number. Ok I have an A, B, C, D, E, F, G, X,
R company. Ok when I start my date and select B I have a counter beggining on
number 1. Then if I select A first of the day in this company will give me 02
instead of 01. Why I don't know need some help. This is the code that I use.
Private Sub Company_AfterUpdate()
Dim count As Variant
Dim compdate As Variant
Dim JDate As Integer
Dim Ydate As Integer '
Dim t As Variant 'Counter variable
Me.Undo
Form.Requery
DoCmd.GoToRecord , , acLast 'Send the page to the last record
compdate = Text31
'MsgBox Text31
DoCmd.GoToRecord , , acNewRec
JDate = Format(Date, "y")
Ydate = Format(Date, "yy")
If JDate < 10 Then
tdate = Company & Ydate & "0" & "0" & JDate & "-" & "01"
End If
If JDate >= 10 Then
tdate = Company & Ydate & "0" & JDate & "-" & "01"
End If
If JDate > 99 Then
tdate = Company & Ydate & JDate & "-" & "01"
End If
'MsgBox [tdate]
If compdate > tdate Or compdate = tdate Then
t = Format(compdate, "!&&")
If t < 99 Then
t = t + 1
t = Format(t, "00")
End If
If JDate < 10 Then
WONum = Company & Ydate & "0" & "0" & JDate & "-" & t
End If
If JDate >= 10 Then
WONum = Company & Ydate & "0" & JDate & "-" & t
End If
If JDate > 99 Then
WONum = Company & Ydate & JDate & "-" & t
End If
Else
WONum = tdate
End If
DoCmd.GoToControl "Model"
End Sub
letter, julian date and a counter number. Ok I have an A, B, C, D, E, F, G, X,
R company. Ok when I start my date and select B I have a counter beggining on
number 1. Then if I select A first of the day in this company will give me 02
instead of 01. Why I don't know need some help. This is the code that I use.
Private Sub Company_AfterUpdate()
Dim count As Variant
Dim compdate As Variant
Dim JDate As Integer
Dim Ydate As Integer '
Dim t As Variant 'Counter variable
Me.Undo
Form.Requery
DoCmd.GoToRecord , , acLast 'Send the page to the last record
compdate = Text31
'MsgBox Text31
DoCmd.GoToRecord , , acNewRec
JDate = Format(Date, "y")
Ydate = Format(Date, "yy")
If JDate < 10 Then
tdate = Company & Ydate & "0" & "0" & JDate & "-" & "01"
End If
If JDate >= 10 Then
tdate = Company & Ydate & "0" & JDate & "-" & "01"
End If
If JDate > 99 Then
tdate = Company & Ydate & JDate & "-" & "01"
End If
'MsgBox [tdate]
If compdate > tdate Or compdate = tdate Then
t = Format(compdate, "!&&")
If t < 99 Then
t = t + 1
t = Format(t, "00")
End If
If JDate < 10 Then
WONum = Company & Ydate & "0" & "0" & JDate & "-" & t
End If
If JDate >= 10 Then
WONum = Company & Ydate & "0" & JDate & "-" & t
End If
If JDate > 99 Then
WONum = Company & Ydate & JDate & "-" & t
End If
Else
WONum = tdate
End If
DoCmd.GoToControl "Model"
End Sub