Basically, I want to extract one column from access base on my query in VBA. My sample code are below, No error were found but the only thing that is working is it just open the excel file were the data from access should be copied.
'Set db = OpenDatabase("\\location\names.mdb")
Set rs = db.OpenRecordset("select first_name from customerinfo " _
& "where datehired between #" & (DTPicker1) & "# and #" & (DTPicker2) & "# ;")
If rs.RecordCount <> 0 Then
Dim x As Integer
Dim count As Integer
Dim PATH, file As String
PATH =("\\location\Extracted Data.xlsm")
file = Right$(PATH, Len(PATH) - InStrRev(PATH, "\"))
Workbooks.Open PATH
Workbooks(file).Activate
count = rs.RecordCount
For x = 2 To count
Workbooks(file).Sheets("extracted").Range("a" & x) = rs.Fields("first_name")
Next
End If'
I should have 3 result to be copied in my excel. can someone help me find what seems to be missing in my code? :(