Í·¼¸Ìì×ö¶«Î÷µÄʱºòÏëµ½µÄÒ»¸ö˼·£¬ÏÖÔÚ¿ÕÏÂÀ´ÍêÉÆһϷ¢ÉÏÀ´ºÍ´ó¼Ò·ÖÏí- '========================================================================================
- '-º¯ Êý Ãû£º AutoNumber
- '-º¯ÊýÓÃ;£º ÉèÖÃ×Ô¶¨Òå×Ô¶¯±àºÅ
- '-²ÎÊý˵Ã÷£º ²ÎÊý1£ºPrefixal----±àºÅǰ׺
- '- ²ÎÊý2£ºDigit----±àºÅλÊý
- '- ²ÎÊý3£ºFieldName----×Ô¶¯±àºÅËùÔÚ×Ö¶ÎÃû
- '- ²ÎÊý4£ºTableName----×Ô¶¯±àºÅËùÔÚ±íÃû
- '-·µ»Ø²ÎÊý£º µ÷Óóɹ¦·µ»Ø½«ÒªÏòмǼÖÐÌí¼ÓµÄ×î´ó±àºÅ£¬µ÷ÓÃʧ°Ü·µ»Ø¿Õ×Ö·û´®""
- '-µ÷Ó÷½·¨£º ÔÚ´°ÌåµÄCurrent(µ±Ç°)ʼþÖе÷ÓÃ
- '-µ÷ÓÃʾÀý£º Me.×Ô¶¯±àºÅ.DefautValue = AutoNumber("[Éó]",7,"×Ô¶¯±àºÅ","ÉóºË±í")
- '-ʹÓÃ×¢Ò⣺ ±íÖеÄ×Ô¶¯±àºÅ×Ö¶ÎÊý¾ÝÀàÐÍÒªÉè³ÉÎı¾ÐÍ
- '-×÷ Õߣº ºì³¾ÈçÑÌ
- '-
- '=============================================================================================
- Function AutoNumber(Prefixal As String, Digit As Integer, FieldName As String, TableName As String) As String
- On Error GoTo AutoNumber_Err
- Dim strMaxID As Long
- Dim strNumberFormat As String
- Dim i As Integer
- strMaxID = Nz(DMax("Right( " & FieldName & "," & Digit & ")", TableName)) + 1
- For i = 1 To Digit
- strNumberFormat = strNumberFormat & "0"
- Next
- AutoNumber = """" & Prefixal & Format(strMaxID, strNumberFormat) & """"
- AutoNumber_Exit:
- Exit Function
- AutoNumber_Err:
- AutoNumber = ""
- MsgBox Err.Number & vbCrLf & Err.Description, vbCritical, "×Ô¶¯±àºÅ³ö´í"
- Resume AutoNumber_Exit
- End Function
¸´ÖÆ´úÂëÓοͣ¬Èç¹ûÄúÒª²é¿´±¾ÌûÒþ²ØÄÚÈÝÇë »Ø¸´ |