Hi Recyan,
plz check the following code.
I am getting the column names from TBL_PITDATA_DATES
and move that as entries to TBL_FORECASTDATES
The first set of code is used to delete the current contents of the table TBL_FORECASTDATES.
The second of code loops thru the table TBL_PITDATA_DATES and fetched the field names correctly (checked using the Message box), bu t i could not insert them to the table TBL_FORECASTDATES (Insert statement highlighted)
please help on how to do this insert. Thanks in advance.
Table TBL_FORECASTDATES contains four fields with first field as DATES into which the contents have to be moved.
Code:
Private Sub Command141_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT TBL_FORECASTDATES.* FROM TBL_FORECASTDATES"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Do Until rs.RecordCount = 0
With rs
.MoveFirst
.Delete
.MoveNext
End With
Loop
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("TBL_PITDATA_DATES")
Dim fld As DAO.Field
For Each fld In rs1.Fields
MsgBox (fld.Name)
insert into ("TBL_FORECASTDATES.DATES") by (fld.Name)
Next
Set fld = Nothing
End Sub
Hi Alansidman, Apologies for cross posting.
Thanks,
Deepan