Hi. I am really stuck with an issue. I am trying to insert date from an orginal table to another table within the same database. However, with the INSERT INTO SQL statements that I have is not giving the correct data from the orginal table. Both orignal table and the new table have text field. I would really appreciate for any suggestions and help!
**************Here is the VBA/SQL code.
Dim db As Database
Dim rec As Recordset
Dim strSQL As String
Dim dtBillingStart, dtBillingEnd As Date
Dim i As Integer
Dim dtTemp As Date
Dim dtBillingMonth
Dim intBlanketNum As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("GRS Detail"
rec.MoveFirst
While Not (rec.EOF)
intBlanketNum = rec("Blanket Number"
For i = 0 To DateDiff("m", dtBillingStart, dtBillingEnd)
DoCmd.SetWarnings False
dtTemp = DateAdd("m", i, dtBillingStart)
strSQL = " INSERT INTO TempTable([Blanket Number]) Values(" & intBlanketNum & " "
MsgBox (intBlanketNum)
DoCmd.RunSQL (strSQL)
Next i
rec.MoveNext
Wend
rec.Close
End Sub
*********This is what I am getting in the results in the new table - and I am not too sure where these numbers came from.
934
933
682
688
*********This is the data from the original table.
1003-302
1003-312
1003-326
1003-341
**************Here is the VBA/SQL code.
Dim db As Database
Dim rec As Recordset
Dim strSQL As String
Dim dtBillingStart, dtBillingEnd As Date
Dim i As Integer
Dim dtTemp As Date
Dim dtBillingMonth
Dim intBlanketNum As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("GRS Detail"
rec.MoveFirst
While Not (rec.EOF)
intBlanketNum = rec("Blanket Number"
For i = 0 To DateDiff("m", dtBillingStart, dtBillingEnd)
DoCmd.SetWarnings False
dtTemp = DateAdd("m", i, dtBillingStart)
strSQL = " INSERT INTO TempTable([Blanket Number]) Values(" & intBlanketNum & " "
MsgBox (intBlanketNum)
DoCmd.RunSQL (strSQL)
Next i
rec.MoveNext
Wend
rec.Close
End Sub
*********This is what I am getting in the results in the new table - and I am not too sure where these numbers came from.
934
933
682
688
*********This is the data from the original table.
1003-302
1003-312
1003-326
1003-341