|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton1_Click()
TextBox1.Value = ""
On Error GoTo 100
Dim CNN As New ADODB.Connection
Dim RST As New ADODB.Recordset
Dim Stpath, strSQL As String
Stpath = ThisWorkbook.Path & Application.PathSeparator & "数据库.mdb"
CNN.Open "provider=Microsoft.jet.OLEDB.4.0;data source=" & Stpath & ";Jet OLEDB:Database Password=" & "888"
If OptionButton1.Value = True Then
strSQL = "SELECT * FROM 可发库存 "
End If
RST.Open strSQL, CNN
Sheet1.Range("A8:L10000").ClearContents
Sheet1.Cells(8, 1).CopyFromRecordset RST
RST.Close
Set RST = Nothing
Set CNN = Nothing
Exit Sub
100:
MsgBox "找不到符合条件的记录", 1 + 16, "系统提示"
End Sub
以上,可发库存 是ACCESS中的表,如果,可发库存是ACCESS中的查询,这个程序应该怎么改?
求高人赐教~~~
[ 本帖最后由 xpz3123 于 2009-12-1 15:28 编辑 ] |
|