|
请教一下,这段代码怎么修改才是对的啊,关键是加上Select就有问题,如何解决,谢谢了!
Public Sub Form_BeforeUpdate(Cancel As Integer)
If Month(Now()) < 10 Then mon = "0" & Month(Now()) Else mon = Month(Now())
If Day(Now()) < 10 Then da = "0" & Day(Now()) Else da = Day(Now())
Me.Label2 = Mid(Year(Now()), 1, 4) & "-" & mon & "-" & da
rq = Mid(Year(Now()), 3, 2) & mon & da
TempidD = Me.Label49
TempidH = Me.Label20
If Mid(Me.Label37, 1, 2) = "SD" Then
Select Case Label20
Case Mid(Me.Label20, 3, 6) <> rq
Me.Label20.value = "CD" & Mid(TempidH, 3, 6) & TempidD & Mid(TempidH, 10, 2) & "2-001" 'sd成品
Case Mid(Me.Label20, 3, 6) = rq
Me.Label20.value = "CD" & Mid(TempidH, 3, 6) & TempidD & Mid(TempidH, 10, 2) & Format(Val(Right(TempidH, 3)) + 1, "000") 'sd成品
ElseIf Mid(Me.Label37, 1, 2) = "SW" Then
Case Mid(Me.Label20, 3, 6) <> rq
Me.Label20.value = "CW" & Mid(TempidH, 3, 6) & TempidD & Mid(TempidH, 10, 2) & "2-001" 'sd成品
Case Mid(Me.Label20, 3, 6) = rq
Me.Label20.value = "CW" & Mid(TempidH, 3, 6) & TempidD & Mid(TempidH, 10, 2) & Format(Val(Right(TempidH, 3)) + 1, "000") 'sd成品
End If
End Sub |
|