呵呵,偶也借楼主的贴问一个问题: 一楼第二个截图为‘产品:表’ 产品:表 中有供应商、类别两个字段,为何转换到设计视图后,两字成了”供应商ID‘,“类别ID’且数据类型均为数字呢。 查看‘供应商ID’的行来源为”SELECT [供应商ID], [公司名称] FROM 供应商 ORDER BY [公司名称]; 请哪位老师释下疑,以解决困扰我许久的问题: Private Sub CommandButton1_Click() Dim cnn As ADODB.Connection Dim RST As ADODB.Recordset Dim sql As String Set cnn = New ADODB.Connection Set RST = New ADODB.Recordset cnn.Open "provider=Microsoft.Jet.OLEDB.4.0;Data source=" & ThisWorkbook.Path & "\mydb.mdb;" If Me.ComboBox1.Value = "" Then sql = "select * from 产品 WHERE 供应商 LIKE '" & Me.ComboBox2.Value & "'" ElseIf Me.ComboBox2.Value = "" Then sql = "select * from 产品 WHERE 类别 LIKE '" & Me.ComboBox1.Value & "'" Else sql = "select * from 产品 WHERE 类别 LIKE '" & Me.ComboBox1.Value & "'" & " and 供应商 like '" & Me.ComboBox2.Value & "'" End If RST.Open sql, cnn, adOpenKeyset, adLockPessimistic‘该处出错 Sheet1.Range("a2").CopyFromRecordset RST(sql) Set cnn = Nothing Set RST = Nothing End Sub |