vb 中 i,无法插入空行,行必须有一个列集值是怎么一回事呢?
第一次运行会说多不操作产生错误,请检查每一步的状态值。再次运行就变成了无法插入空行,行必须有一个列集值
Option Explicit
Private Sub cmdExit_Click()
Unload Me '关闭购物车创建窗体
End Sub
Private Sub cmdOk_Click()
On Error GoTo DoError
Dim strSQL As String, objCom As Command
If Trim(txtUser) = "" Then
MsgBox "请输入客户姓名!", vbCritical, "创建购物车"
txtUser = ""
txtUser.SetFocus
Else
With Drug_Store.rsShoppingCars
.AddNew
.Fields("编号") = txtNumber
.Fields("客户名") = txtUser
.Fields("日期") = Date & " " & Format(Time, "hh:nn")
.Update
strSQL = "Create Table " & txtNumber _
& "( 编号 nchar(6) primary key, 数量 Smallmoney not null)"
Set objCom = New Command
Set objCom.ActiveConnection = Drug_Store.DataCon
= strSQL
= adCmdText
objCom.Execute
MsgBox txtUser & "购物车创建成功!编号:" & txtNumber, _
vbInformation, "创建购物车"
Set objCom = Nothing
End With
End If
Exit Sub
DoError:
MsgBox Err.Description
End Sub
Private Sub cmdRefresh_Click()
Dim strNum As String
With Drug_Store.rsShoppingCars
If .State = adStateClosed Then .Open
If .RecordCount < 1 Then
strNum = Format(Date, "yymmdd") & "00001"
Else
.MoveLast
strNum = Right(.Fields("编号"), 5)
strNum = Format(Val(strNum) + 1, "00000")
strNum = Format(Date, "yymmdd") & strNum
End If
End With
txtNumber = "T" & strNum
txtUser = ""
txtUser.SetFocus
End Sub
Private Sub Form_Load()
Dim strNum As String
With Drug_Store.rsShoppingCars
If .State = adStateClosed Then .Open
.Requery
.Filter = "日期 Like '" & Date & "%'"
If .EOF Then
strNum = Format(Date, "yymmdd") & "00001"
Else
.MoveLast
strNum = Right(.Fields("编号"), 5)
strNum = Format(Val(strNum) + 1, "00000")
strNum = Format(Date, "yymmdd") & strNum
End If
End With
txtNumber = "T" & strNum
End Sub