Importing data into Excel from Access Error

mrgreen

Registered User.
Local time
Today, 04:50
Joined
Jan 11, 2008
Messages
60
Howdy,

I have written a Function to calculate the Monday of any date that is entered into my db. This works great and life is/was good until I tried building a front end in Exel for graphing purposes. When I try and run my code I get a Runtime Error saying Excel doesn't recognize the function. How do I get around this (do I?). Any help would be great!


Function LastMonday(x As Date) As Date
Dim bToday As Byte, intDayDif As Integer
bToday = DatePart("w", x)
intDayDif = (bToday - vbMonday)
If intDayDif = -1 Then
LastMonday = DateAdd("d", -6, x)
Else
LastMonday = DateAdd("d", -(intDayDif), x)
End If
End Function


Excel Code (When User Form opens)
strSQL = "SELECT DISTINCT([Week Audit]) FROM QRYGENERALINFO"
strSQL = strSQL & " ORDER BY [Week Audit] DESC;"
'Establish ADO paramters 2007============================================================
strpath = "\\xxx\xxx\xxx\Mydb.accdb"
strconn = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & strpath & ";"
'====================================================================================
cnt.Open strconn
Set rst = cnt.Execute(strSQL)
 

Users who are viewing this thread

Back
Top Bottom