Greetings everyone,
I am working on a scheduling tool and have a temp table that I am attempting to loop through to pull the necessary info out of before deleting.
I am using Access '97 on Windows XP.
Here is my code:
[code=text]
Private Sub ScheduleParts_C lick()
Dim ScheduleParts As Recordset
Dim mySQL As String
Dim ActTime As Single
Dim RunHours As Single
Dim EndTime As Date
Dim db As Database
Set db = CurrentDb()
Set ScheduleParts = db.OpenRecordse t("QueueInfo" )
ScheduleParts.M oveFirst
Do Until ScheduleParts.E OF
ActTime = [S1] / [ProdEff]
RunHours = ActTime * [Qty] + [SetupTime]
EndTime = [StartTime] + RunHours
mySQL = "INSERT INTO Schedule (FGPartNum,GBPa rtNum,Qty,Day,D ia,Length,Setup ,CCYTime,ActTim e,RunHours,Star tTime,EndTime) " _
& " VALUES(PartNum, GB1,Qty,bucketD ay,Dia,Length,S etupTime,S1," _
& ActTime & "," & RunHours & ",#" & StartTime & "#,#" & EndTime & "#);"
DoCmd.RunSQL mySQL
ScheduleParts.M oveNext
Loop
ScheduleParts.C lose
db.Close
Set ScheduleParts = Nothing
Set db = Nothing
End Sub
[/code]
In testing, I have 9 records in my temp table. My code adds the first record from the temp table 9 times. My recordset "QueueInfo" is a saved query in the database. I did try to compare the records from the temp table to existing records in my destination table to prevent duplicates, but ran into a number of other issues.
I've been wrestling with this one for a few days now and haven't been able to figure it out. Any help you could provide would be appreciated.
I am working on a scheduling tool and have a temp table that I am attempting to loop through to pull the necessary info out of before deleting.
I am using Access '97 on Windows XP.
Here is my code:
[code=text]
Private Sub ScheduleParts_C lick()
Dim ScheduleParts As Recordset
Dim mySQL As String
Dim ActTime As Single
Dim RunHours As Single
Dim EndTime As Date
Dim db As Database
Set db = CurrentDb()
Set ScheduleParts = db.OpenRecordse t("QueueInfo" )
ScheduleParts.M oveFirst
Do Until ScheduleParts.E OF
ActTime = [S1] / [ProdEff]
RunHours = ActTime * [Qty] + [SetupTime]
EndTime = [StartTime] + RunHours
mySQL = "INSERT INTO Schedule (FGPartNum,GBPa rtNum,Qty,Day,D ia,Length,Setup ,CCYTime,ActTim e,RunHours,Star tTime,EndTime) " _
& " VALUES(PartNum, GB1,Qty,bucketD ay,Dia,Length,S etupTime,S1," _
& ActTime & "," & RunHours & ",#" & StartTime & "#,#" & EndTime & "#);"
DoCmd.RunSQL mySQL
ScheduleParts.M oveNext
Loop
ScheduleParts.C lose
db.Close
Set ScheduleParts = Nothing
Set db = Nothing
End Sub
[/code]
In testing, I have 9 records in my temp table. My code adds the first record from the temp table 9 times. My recordset "QueueInfo" is a saved query in the database. I did try to compare the records from the temp table to existing records in my destination table to prevent duplicates, but ran into a number of other issues.
I've been wrestling with this one for a few days now and haven't been able to figure it out. Any help you could provide would be appreciated.
Comment