最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【生成指定范圍隨機整數(shù)】【生成重復(fù)代碼】【生成自定義編號】

2022-10-29 14:54 作者:凌霄百科  | 我要投稿

生成指定范圍隨機整數(shù)


Private Sub Command生成_Click()

If Me.最小值 <> "" And Me.最大值 <> "" Then

Dim minnum As Long

Dim maxnum As Long

minnum = Me.最小值

maxnum = Me.最大值

? ? If minnum > maxnum Then

? ? MsgBox "最小值不能大于最大值"

? ? End If

? ? Randomize

? ? Me.隨機數(shù) = Int(minnum + (maxnum - minnum + 1) * Rnd())

Else

MsgBox "請輸入范圍"

End If

End Sub


生成重復(fù)代碼

Private Sub Command清空_Click()

DoCmd.SetWarnings (False)

Dim del_sql As String

del_sql = "Delete From 項目表"

DoCmd.RunSQL del_sql

Me.數(shù)據(jù)表子窗體.Requery

End Sub


Private Sub Command生成_Click()

If Me.替換變量 <> "" And Me.生成代碼 <> "" Then

Me.生成結(jié)果 = ""

Dim search_rs As DAO.Recordset

Dim search_sql As String

search_sql = "Select * From 項目表"

Set search_rs = CurrentDb.OpenRecordset(search_sql, dbOpenDynaset)

Dim addcodetext As String

Dim codeitem As String


Do While search_rs.EOF = False

codeitem = Replace(Me.生成代碼, Me.替換變量, search_rs!項目.Value)

addcodetext = addcodetext & vbCrLf & codeitem

search_rs.MoveNext

Loop

search_rs.Close

Set search_rs = Nothing

Me.生成結(jié)果 = addcodetext

Else

Me.生成結(jié)果 = ""

End If

End Sub


生成自定義編號

Private Sub Command添加_Click()

On Error GoTo 添加失敗錯誤


If 記錄編號 = "" Or IsNull(記錄編號) = True Then

MsgBox "記錄編號值為空!"

Exit Sub

End If


If 類型 = "" Or IsNull(類型) = True Then

MsgBox "類型值為空!"

Exit Sub

End If

If 金額 = "" Or IsNull(金額) = True Then

MsgBox "金額值為空!"

Exit Sub

End If

If 客戶 = "" Or IsNull(客戶) = True Then

MsgBox "客戶值為空!"

Exit Sub

End If

If 日期 = "" Or IsNull(日期) = True Then

MsgBox "日期值為空!"

Exit Sub

End If




Dim add_rs As DAO.Recordset

Set add_rs = CurrentDb.OpenRecordset("銷售數(shù)據(jù)表", dbOpenTable)

With add_rs

.AddNew

!記錄編號.Value = 記錄編號.Value

!類型.Value = 類型.Value

!金額.Value = 金額.Value

!客戶.Value = 客戶.Value

!日期.Value = 日期.Value

!備注.Value = 備注.Value

.Update

.Close

End With

Set add_rs = Nothing


Me.數(shù)據(jù)表子窗體.Requery

Exit Sub

添加失敗錯誤:

MsgBox "添加失??!"

MsgBox Err.Description

End Sub


Function 生成自定義編號(ByVal numdate As Date, ByVal numtype As String) As String

On Error GoTo 錯誤

Dim search_num As String

If numtype = "銷售" Then

search_num = "XS-" & Format(numdate, "YYYYMMDD")

Else

search_num = "TH-" & Format(numdate, "YYYYMMDD")

End If

Dim num_count As Long

num_count = Nz(DCount("記錄編號", "銷售數(shù)據(jù)表", "記錄編號 like '*" & search_num & "*'"), 0) + 1

生成自定義編號 = search_num & "-" & Format(num_count, "000")

Exit Function

錯誤:

生成自定義編號 = ""


End Function


Private Sub 記錄編號_DblClick(Cancel As Integer)

If 類型 = "" Or IsNull(類型) = True Then

MsgBox "類型值為空!"

Exit Sub

End If

If 日期 = "" Or IsNull(日期) = True Then

MsgBox "日期值為空!"

Exit Sub

End If

Me.記錄編號 = 生成自定義編號(Me.日期, Me.類型)

End Sub


【生成指定范圍隨機整數(shù)】【生成重復(fù)代碼】【生成自定義編號】的評論 (共 條)

分享到微博請遵守國家法律
肇东市| 三门峡市| 巴林右旗| 平阳县| 博兴县| 呼伦贝尔市| 怀来县| 新兴县| 枣阳市| 深水埗区| 伊金霍洛旗| 读书| 江永县| 大理市| 元阳县| 建水县| 永康市| 巴林左旗| 吉木乃县| 天镇县| 昌都县| 赫章县| 泰来县| 易门县| 濮阳县| 平度市| 仁化县| 新郑市| 开远市| 弥渡县| 孟村| 芦溪县| 若羌县| 江达县| 太和县| 盐池县| 浦江县| 繁峙县| 湛江市| 广水市| 乐亭县|