Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 1st, 2005, 09:13 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to translate a code in DAO to ADO

please can you help me, i want to use the ADO, but i have some problem, can you translate me please that code in ADO

Dim db As DAO.Database, rst As DAO.Recordset
    Dim SQL As String
    Dim date As Date
    ' open the database
    Set db = CurrentDb()
    SQL = "SELECT Max(the_date) FROM time_by_day"
    ' open the recordset
    Set rst = db.OpenRecordset(SQL, dbOpenForwardOnly, dbReadOnly)
    date_a_ajouter = DateAdd("d", 1, DateValue(rst.Fields(0)))
    While DateDiff("d", date_a_ajouter, Now) > 0
        SQL = "INSERT INTO time_by_day (the_date,the_month,the_year,day_of_month,week_of_ year,month_of_year,quarter) VALUES('" & date & "','" & MonthName(Month(date)) & "','" & Year(date) & "','" & Day(date) & "','" & DatePart("ww", date) & "','" & DatePart("m", date_a_ajouter) & "','Q" & DatePart("q", date) & "')"
        db.Execute SQL
        date = DateAdd("d", 1, date)
    Wend

    ' close the Recordset
    rst.Close
Reply With Quote
  #2 (permalink)  
Old July 6th, 2005, 11:37 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Why not try an Update query and then just do:

DoCmd.SetWarnings = False
DoCmd.OpenQuery "qryYourUpdateQueryName"
DoCmd.SetWarnings = True




mmcdonal
Reply With Quote
  #3 (permalink)  
Old July 7th, 2005, 10:19 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Salisbury, Wiltshire, United Kingdom.
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to leehambly
Default

Alternatively, you could create the sql statement in the same way you have in your original post and then use it in a RunSQL command...

'-----------------------------
SQL = "INSERT INTO time_by_day (the_date,the_month,the_year,day_of_month,week_of_ year,month_of_year,quarter) VALUES('" & date & "','" & MonthName(Month(date)) & "','" & Year(date) & "','" & Day(date) & "','" & DatePart("ww", date) & "','" & DatePart("m", date_a_ajouter) & "','Q" & DatePart("q", date) & "')"

docmd.runsql(SQL)
'------------------------------

Either way (this way or mmcdonal's), you are not using DAO or ADO.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
DAO vs. ADO SerranoG Access VBA 11 December 5th, 2006 01:19 PM
how to convert this DAO connection code to ADO Con ruth26 VB Databases Basics 0 May 11th, 2006 06:15 AM
DAO / ADO? merguvan Access VBA 8 January 18th, 2004 07:39 AM
converting DAO code to ADO Khalifeh Access 25 November 4th, 2003 01:22 PM
How to connect .dbf file with ADO & DAO with code cbpanchal VB How-To 4 July 28th, 2003 11:14 PM



All times are GMT -4. The time now is 04:34 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.