|
 |
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 .
|
 |
|
|
 |

July 1st, 2005, 08:13 AM
|
Registered User
|
|
Join Date: Jul 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

July 6th, 2005, 10:37 AM
|
Friend of Wrox
|
|
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
|
|
Why not try an Update query and then just do:
DoCmd.SetWarnings = False
DoCmd.OpenQuery "qryYourUpdateQueryName"
DoCmd.SetWarnings = True
mmcdonal
|

July 7th, 2005, 09:19 AM
|
Friend of Wrox
|
|
Join Date: Sep 2003
Location: Salisbury, Wiltshire, United Kingdom.
Posts: 155
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |