View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
headly headly is offline
external usenet poster
 
Posts: 45
Default Chartspace Data Source and Connection String Problem

I've embedded the activex chart control on a form. It needs to pull data from
an access database. When hardcoded into properties, the chart works fine, but
I'd like to dynamically be able to pull the data from whatever directory the
file may reside in.
Here's the code that isn't working, thoughts appreciated

'Create variable for connection string less path

Dim strConnection As String
'The access db has the same name as the workbook
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Left(ActiveWorkbook.FullName, Len(ActiveWorkbook.FullName) - 4) &
".mdb;Persist Security Info=False;Jet OLEDB:Database Password=;"

frmMain.ChartSpace1.ConnectionString = strConnection
frmMain.ChartSpace1.DataMember = "qryDJIA"
frmMain.ChartSpace1.Refresh