needhelpwithvba
New Member
- Joined
- Aug 5, 2011
- Messages
- 4
Hi,
I'm trying to export specific rows from Access to Excel given a particular parameter defined in cell D32 of my Excel sheet (in this case the value for Dogs must be equal to what is in cell D32). Below is the portion of code that is not working:
Const strDb As String = "C:\Pets.mdb"
Const strQry As String = "SELECT * from [Canines] WHERE ([Canines].[Dogs]=Range("D32").Value)"
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Ace.OLEDB.12.0; Persist Security Info = False; " & "Data Source=C:\Pets.mdb;"
Set rs = New ADODB.Recordset
The code is specifically not happy with 'Range("D32").Value'. I've tried replacing that part of code with the number 3 and it works fine in that case. Any help would be greatly appreciated!!
I'm trying to export specific rows from Access to Excel given a particular parameter defined in cell D32 of my Excel sheet (in this case the value for Dogs must be equal to what is in cell D32). Below is the portion of code that is not working:
Const strDb As String = "C:\Pets.mdb"
Const strQry As String = "SELECT * from [Canines] WHERE ([Canines].[Dogs]=Range("D32").Value)"
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Ace.OLEDB.12.0; Persist Security Info = False; " & "Data Source=C:\Pets.mdb;"
Set rs = New ADODB.Recordset
The code is specifically not happy with 'Range("D32").Value'. I've tried replacing that part of code with the number 3 and it works fine in that case. Any help would be greatly appreciated!!