|
4#
楼主 |
发表于 2011-11-30 23:35:52
|
只看该作者
andymark 发表于 2011-11-29 15:11
可以的,可能你的语句中少了按类别分类取值的条件
贴出你的语句
新手刚学,所以不懂的太多了,麻烦支个招哈,谢谢!
Private Sub 广告类型_AfterUpdate()
On Error GoTo Err_广告类型_Click
Dim myrecordset, mylookup As Variant
Dim number As Variant
'DoCmd.GoToRecord , , acNewRec
'If MsgBox("您确定要新编号吗?选是将编新号,而且不能更改和删除", vbYesNo, "关闭!") = vbNo Then
'End
'End If
mylookup = DLookup("类型代码", "广告资源编号")
If IsNull(mylookup) Then
Set myrecordset = CurrentDb.OpenRecordset("广告资源编号")
myrecordset.AddNew
myrecordset("类型代码") = Me.广告类型.Value
myrecordset("广告编号") = 1
myrecordset.Update
number = 1
'End If
Else
Set myrecordset = CurrentDb.OpenRecordset("广告资源编号")
number = myrecordset("广告编号") + 1
myrecordset.Edit
myrecordset("广告编号") = number
myrecordset.Update
'ElseIf Format(mylookup, "yyyy/mm") < Format("广告编号", "yyyy/mm") Then
'Set myrecordset = CurrentDb.OpenRecordset("广告资源编号")
'myrecordset.Edit
'myrecordset("类型代码") = Me.广告类型.Value
'myrecordset("广告编号") = 1
'myrecordset.Update
'number = 1
End If
Me![广告位编号] = Me.广告类型.Value & Format(number, "000")
'Me.广告类型.
Exit_广告类型_Click:
Exit Sub
Err_广告类型_Click:
MsgBox Err.Description
Resume Exit_广告类型_Click
End Sub |
|