Gustav Brock
Gustav at cactus.dk
Tue Nov 17 08:21:21 CST 2009
Hi Chester
Use DAO. Something like:
<code>
Public Function CopyRecord() As Boolean
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rstAdd As DAO.Recordset
Dim fld As DAO.Field
Dim strFld As String
Dim intDay As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Select * From tblTable Where [DateField] = DateSerial(Year(Date), Month(Date), 1);")
Set rstAdd = rst.Clone
With rstAdd
For intDay = 2 To Day(DateSerial(Year(Date), Month(Date) + 1, 0))
.AddNew
For Each fld In rstAdd.Fields
With fld
strFld = .Name
If Not strFld = "Id" Then
If strFld = "NameOfYourDateField" Then
.Value = DateSerial(Year(Date), Month(Date), intDay)
Else
.Value = rst.Fields(strFld).Value
End If
End If
End With
Next
.Update
Next
.Close
End With
rst.Close
Set fld = Nothing
Set rstAdd = Nothing
Set rst = Nothing
Set dbs = Nothing
End Function
</code>
/gustav
>>> Chester_Kaup at kindermorgan.com 17-11-2009 14:39 >>>
I have a table that has one record on the first day of each month. I need to duplicate this record for each day of the month. I need help on how to do this. Thanks.
Chester Kaup
Engineering Technician
Kinder Morgan CO2 Company, LLP
Office (432) 688-3797