UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Inaccess 2007 What Is The New Dao Code Equivalent, Office 2007    
 
   
Leah
post Feb 6 2012, 02:56 PM
Post #1

UtterAccess Guru
Posts: 501
From: New York, New York



I know I asked something along this line a year and a half ago, but I have no idea what database I used it for.
I am starting with a fresh database rather than doing an upgrade because there is a corruption in the Access 2000 database.
Below is some code that worked in Access 2000. ADODB is not available in Access 2007 so what is the equivalent DAO code to use?
Dim ADOrs As ADODB.Recordset
Dim sql_code As String
Dim date_grab As String
Dim path As String
'various stuff
sql_code = "SELECT TOP 1 [todate]-1 AS dateminus1 FROM [Provisions vs Write Offs]"
Set ADOrs = New ADODB.Recordset
ADOrs.CursorLocation = adUseClient
ADOrs.Open sql_code, CurrentProject.Connection
date_grab = Format(ADOrs.Fields("dateminus1").Value, "Medium Date")
path = "Q:\GPMS\Finance\Access_Reporting\Aged_WIP_vs_Write_Offs\Provisions_vs_WO_US_Output\Provisions_vs_Write_Offs_Contract_" & date_grab & ".xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Provisions vs Write Offs Query", path, True

'etc
Go to the top of the page
 
+
theDBguy
post Feb 6 2012, 03:29 PM
Post #2

Access Wiki and Forums Moderator
Posts: 58,014
From: SoCal, USA



Hi Leah,
DODB is still available in 2007. Make sure you have a reference set to something like "Microsoft ActiveX Data Objects 2.x Library."
Just my 2 cents... 2cents.gif
Go to the top of the page
 
+
Leah
post Feb 6 2012, 04:22 PM
Post #3

UtterAccess Guru
Posts: 501
From: New York, New York



Thanks that is good to know that it is available if I add a reference in case I do not have luck in converting.
However I thought that DAO's might require less code and I am afraid that ADO's are going to go away as it was not there in a straight forward manner.
In the meanwhile I looked around some more on the Web and played with it and at least for this nonsophisticated code, the below seems to wrok.
Dim rs As dao.Recordset
Dim sql_code As String
Dim date_grab As String
Dim path As String
sql_code = "SELECT TOP 1 [todate]-1 AS dateminus1 FROM [Provisions vs Write Offs]"
Set rs = CurrentDb.OpenRecordset(sql_code, dbOpenDynaset)
date_grab = Format(rs.Fields("dateminus1").Value, "Medium Date")

etc.
Go to the top of the page
 
+
theDBguy
post Feb 6 2012, 05:22 PM
Post #4

Access Wiki and Forums Moderator
Posts: 58,014
From: SoCal, USA



Okay. Glad to hear you were able to manage.
Good luck with your project. .gif" style="vertical-align:middle" emoid=":thumbup:" border="0" alt="thumbup.gif" />
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 14th September 2014 - 11:00 PM