解决如下:
Dim stID As String
If IsNull(Me.OpenArgs) Then
Dim day As String
If IsNull(DLookup("订单ID", "订单")) Then '检查表内是否有数据
stID = "RK" & Format(Date, "yyyymm") & "001"
Else
day = Mid(DMax("订单ID", "订单"), 3, 6) '取出编号中的日期
If day = Format(Date, "yyyymm") Then '对比日期
stID = "RK" & Format(Date, "yyyymm") & Format(CLng(Mid(DMax("订单ID", "订单"), 9, 11) + 1), "000")
Else
stID = "RK" & Format(Date, "yyyymm") & "001"
End If
End If
Else
stID = Me.OpenArgs
End If
Set mADOTransForm = New ADOTransForm
mADOTransForm.InitForm Me, "Select * From 订单 Where 订单ID='" & stID & "'", Me.订单明细_子窗体, "Select * From 订单明细 Where 订单ID='" & stID & "'"
If mADOTransForm.FormDataMode Then
Me.Caption = "添加订单"
Me.订单ID.DefaultValue = "'" & stID & "'"
Else
Me.Caption = "编辑订单"
End If
在这里要感谢HI-WZJ版主一对一的辅导,版主当时提到引号的问题.对于帮助本帖的其他老师一并致谢!作者: hi-wzj 时间: 2010-3-24 10:44
建议将问题所在窗体标识出来,便于大家查看。作者: loginwjd303 时间: 2010-3-24 11:55
如何才能将其中的订单ID改成如 RA-100324-001 增量为1的自定义编号作者: chuang0321 时间: 2010-3-24 12:26
利用VBA语言,X代表需要递增的ID文本数据,y用于进行最后三位数的递增计算
Private Sub Form_Load()
Dim x As String
Dim y As Integer
x = "RA-100324-099"
y = Right(x, 3) + 1
If y < 10 Then
x = Left(x, 12)
Else
If y >= 10 And y < 100 Then
x = Left(x, 11)
Else
If y >= 100 Then
x = Left(x, 10)
End If
End If
End If