|
代码如下
Private Sub Command36_Click()
Dim rs As ADODB.Recordset
Dim StrTemp As String
Dim iTemp As Integer
Dim XTong As Boolean
On Error GoTo Err_保存_Click
XTong = False
'打开“秤房数据”表
Set rs = New ADODB.Recordset
StrTemp = "Select * From 秤房数据"
rs.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'如果“秤房数据”表为空,则XTong的值为False
If rs.RecordCount <= 0 Then
XTong = False
Else
'在“秤房数据”表查找是否存在与待保存的记录相同
rs.MoveFirst
For iTemp = 0 To rs.RecordCount - 1
If (rs("车号") = Me![车号]) And (rs("毛重日期") = Me![毛重日期]) Then
XTong = True
iTemp = rs.RecordCount + 1
Else
rs.MoveNext
End If
Next iTemp
End If
'在“秤房数据”表中保存该记录的其他信息
If XTong = True Then
rs("采样编号") = Me![采样编号]
rs("验收日期") = Format(Me.验收时间, "m-d-yyyy hh:mm")
rs("是否退货") = Me![Check14]
rs("退货原因") = Me![退货原因]
rs("是否退货") = Me![Check14]
rs("规格") = Me![Combo18]
rs("扣吨") = Me![扣吨]
rs("扣吨原因") = Me![原因]<o |
|