Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 22nd, 2008, 06:24 AM
Authorized User
Join Date: Jul 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rolling headers (13 months) how to update records


I have been struggling with ADODB to solve this:
1. I create a table with solid row data and headers.
2. I update the last 13 column headers with rolling months as below.

Sub SetMyColumns()
Dim myConn
Dim tbl, newCol, adox, n

Set myConn = CurrentProject.Connection

    tbl = "MyTable"

    Set adox = CreateObject("ADOX.Catalog")
    adox.ActiveConnection = myConn
    For n = 0 To 12
    newCol = Year(DateAdd("m", n, (Now()))) & "-" & Right(0 & Month(DateAdd("m", n, Now())), 2)
    adox.Tables(tbl).Columns("M+" & n).Name = newCol
    Set adox = Nothing
    Set myConn = Nothing

End Sub

3. Until now I'm fine, but then:
- I'm picking values from another table along with month number and need to place this data by matching month into "MyTable".

The problem is how to save the source data (myValue) to "MyTable" to correct columns? myData connects nicely to "MyTable" but I cannot use it like this (get error msg):

Do Until myData.EOF

from 0 to 12
myData!rollCol = myValue/13 <== This fails!!
(here I set next month to rollCol)


rollCol points to actual month to actual+12 months
e.g. 2008-05, 2008-06, 2008-07 .....2009-05

I have not set any specific Dimension for rollCol, should I?

Thanks in advance

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lets get this forum rolling! SQLScott Windows Communication Foundation 6 August 9th, 2011 10:01 PM
Update Multiple Records cancer10 Classic ASP Databases 0 October 25th, 2006 01:01 AM
Update Records bspeck Dreamweaver (all versions) 5 October 5th, 2004 03:05 PM
UPDATE RECORDS!!! a_pathak BOOK: Beginning ASP 3.0 1 March 3rd, 2004 04:00 AM
Help! Cannot update records mcalder Classic ASP Databases 6 August 14th, 2003 01:54 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.