hello! i'm just new in here.. I started practicing vba programming since yesterday... pls help me on my problem...
I've already connected my records at ms access.. the macro i made is only runnable at 1st row of my table.. so i made a loop to fill up the next rows with data..
but i got these error..
Run-time error '3705':
Operation is not allowed when the object is open
here's my code:
________________________________________
Sub PriceListComputation()
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim row As Integer
con.ConnectionString = "DBQ=C:\PriceList.mdb; " & "DRIVER={Microsoft Access Driver (*.mdb)}"
con.Open
Set rs.ActiveConnection = con
row = ActiveSheet.UsedRange.Rows.Count
For moveRow = 7 To (row - 22) 'here's the loop i made where i got error.
rs.Open "SELECT * FROM Uniforms WHERE item_name = '" & ActiveSheet.Cells (moveRow, 2) & "'"
Next
startRow = 7 'this is the loop on the first row of my table, but didn't work at next
Do Until rs.EOF
Cells(startRow, 2) = rs.Fields(2).Value
Cells(startRow, 7) = rs.Fields(3).Value
Cells(startRow, 6) = rs.Fields(5).Value
rs.MoveNext
startRow = startRow + 1
Loop
rs.Close
Set rs = Nothing
con.Close
Set con = Nothing
End Sub
_________________________________________
I got the logic but i don't know how to code it properly..
still got many questions to ask.. but my priority was this one.. help me plz.. thanks in advance
Bookmarks