Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003

    Unanswered: Help to programmatically add data

    Ok, hope I can get some help on this. I want to programmatically add new records maybe in MS Access Module. I would like to see a sample in the simplest form such as adding a new record for each day of the week for the entire year to an existing table. The new record can consist of ID (auto number) and Date. So the first few records in the table would look like this:
    ID Date
    1 01/01/2004
    2 02/01/2004
    3 03/01/2004
    The module would loop until it hits Dec 31/2004. If I can get a sample, I can maybe alter it to reflect my actual data.

    Thanks in advance for any help.


  2. #2
    Join Date
    Aug 2003

    Re: Help to programmatically add data

    Ok, figured this one out. I just used the Module in Access and did some VB ADO to add new records. I also did not want to add weekends so I set my dates and checked for what day it was and if Sat, add 48 hours or if Sun. add 24 hours. If statements jump over weekends instead of adding to my table. Works well. Now I can add all employees standard Mon to Fri hours for the entire year in a matter of seconds....



  3. #3
    Join Date
    Feb 2002
    Dim rst As ADODB.Recordset
    Dim strSQL As String
    Dim dteI As Date
        Set rst = New ADODB.Recordset
        strSQL = "SELECT * FROM MyTable"
        rst.Open strSQL, CurrentProject.Connection, adOpenKeyset, adLockPessimistic
        dteI = Date
        With rst
        Do Until dteI = #12/31/2004#
        .Fields("myDate") = dteI
        dteI = DateAdd("d", 1, dteI)
        Set rst = Nothing
    Haven't checked this but it is about correct. Using ADO recordset.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts