Private Sub Form_Load() PH.Locked = True End Sub Private Sub PH_GotFocus() Dim a As Long Dim b As Long a = Format(Date, "yyyymmdd") b = Left(DMax("PH", "商品资料"), 12) If Me![PH] <> "" Then Exit Sub End If If b >= a Then Me![PH] = DMax("PH", "商品资料") + 1 Else Me![PH] = Format(Date, "yyyymmdd") & 0 & 0 & 0 + 1 End If PH.Locked = True End Sub Private Sub PH_LostFocus() PH.Locked = False End Sub
Option Compare Database
Private Sub Form_Load()
PH.Locked = True
End Sub
Private Sub PH_GotFocus()
Dim a As Long
Dim b As Long
a = Format(Date, "yyyymmdd")
b = Left(DMax("PH", "商品资料"), 50)
If Me![PH] <> "" Then
Exit Sub
End If
If b >= a Then
Me![PH] = DMax("PH", "商品资料") + 1
Else
Me![PH] = Format(Date, "yyyymmdd") & 0 & 0 & 0 + 1
End If
PH.Locked = True
End Sub
Private Sub PH_LostFocus()
PH.Locked = False
End Sub