두 개의 매개 변수를 기반으로 Access에서 Excel로 데이터를 가져 오려고합니다. 프로젝트 번호 (매개 변수 1)와 도구 유형 (매개 변수 2)을 지정하는 도구 목록이 있습니다. 이 두 매개 변수의 사용자 입력을 만족시키지 못하는 도구를 필터링하려면 어떻게합니까? 두 개의 매개 변수를 기반으로 Access 테이블에서 Excel로 가져 오기
나는이 스레드 보았다 Import to Excel from Access table based on parameters을하지만 여러 매개 변수에 대해 이야기하지 않습니다. 내가 초점을 얻고 SelectedProj에 값을 삽입 할 필요가 어디
Dim cn As Object
Dim rs As Object
Dim strFile As String
Dim strCon As String
Dim strSQL As String
Dim s As String
Dim i As Integer, j As Integer
''Access database
strFile = "D:\Tool_Database\Tool_Database.mdb"
''This is the Jet 4 connection string, you can get more
''here : http://www.connectionstrings.com/excel
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile & ";"
''Late binding, so no reference is needed
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open strCon
'Find the name of the tool that was selected
Dim SelectedTool As String, SelectedProj
Set SelectedTool = Tools_ListBox.Selected
Set SelectedProj = Project_ListBox.Selected
strSQL = "SELECT * " _
& "FROM ToolFiles " _
& "WHERE Tool_Name = '" & SelectedTool & "'"
rs.Open strSQL, cn, 3, 3
Worksheets("ToolList").Cells(2, 1).CopyFromRecordset rs
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
은 분명히 STRSQL 문입니다 : 내가 지금까지에 어딘지 여기에있다.
감사합니다.