以下是程序Option ExplicitPublic adoCnn As New ADODB.Connection
Public Rs, Rs2 As New ADODB.RecordsetPublic Sub Connection()
If adoCnn.State = adStateOpen Then
adoCnn.Close
End If
adoCnn.Provider = "Microsoft.Jet.OLEDB.4.0"
adoCnn.Open App.Path & "\瓶盖.mdb"
End SubPrivate Sub CmdCancel_Click()
FrmMain.Show
Unload Me
End SubPrivate Sub CmdOk_Click()
Dim strSQl As String
Dim temp As IntegerIf ChkSale.Value = 1 Then
strSQl = "select * from 出售"
Call Connection
Rs.CursorLocation = adUseClient
Rs.Open strSQl, adoCnn, adOpenDynamic, adLockOptimistic
Rs.AddNew
Rs.Fields(1) = TextMarket.Text
Rs.Fields(2) = TextNombreG.Text
Rs.Fields(3) = TextNombreP.Text
Rs.AddNew
End IfIf ChkRecede = 1 Then
strSQl = "select * from 回收"
Call Connection
Rs.CursorLocation = adUseClient
Rs.Open strSQl, adoCnn, adOpenDynamic, adLockOptimistic
Rs.AddNew
Rs.Fields(1) = TextMarket.Text
Rs.Fields(2) = TextNombreG.Text
Rs.Fields(3) = TextNombreP.Text
Rs.AddNew
End Iftemp = MsgBox("是否继续输入?", vbYesNo)
If temp = 6 Then
TextMarket.Text = ""
TextCode.Text = ""
TextNombreG.Text = ""
TextNombreP.Text = ""
Else
FrmMain.Show
Unload Me
End If
End SubPrivate Sub DataGrid1_Click()
TextMarket.Text = Rs2.Fields(0)
End SubPrivate Sub TextCode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Dim strSQL3, temp As String
temp = TextCode.Text
strSQL3 = "select * from 商店 where 商店代码 = '" + CStr(temp) + "'"
Call Connection
Rs2.CursorLocation = adUseClient
Rs2.Open strSQL3, adoCnn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = Rs2
End If
End SubPrivate Sub TextNombreG_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call CmdOk_Click
End If
End SubPrivate Sub TextNombreP_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call CmdOk_Click
End If
End Sub