FreshCoder
Registered User.
- Local time
- Today, 03:48
- Joined
- Sep 22, 2018
- Messages
- 33
Hi again!
I need to insert planks from planks table into planksOK table. They are only allowed to be 200cm, so if they are over they need to be cut.(300 cm = 200 + 100 and so on). Remaining length will be placed in own columns in planksOK.
I have managed to insert 200cm and below.
So if anyone can help me out it would be good
Sorry for bad english
I need to insert planks from planks table into planksOK table. They are only allowed to be 200cm, so if they are over they need to be cut.(300 cm = 200 + 100 and so on). Remaining length will be placed in own columns in planksOK.
I have managed to insert 200cm and below.
So if anyone can help me out it would be good

Sorry for bad english
Code:
Option Compare Database
Option Explicit
Private Sub comCut_Click()
Dim strsql As String
Dim stdset As DAO.Recordset
Dim maxlength As Integer, LengthCM As Integer, LenghtOK As Integer, LengthRest1 As Integer, Lengthrest2 As Integer
'empty result
strsql = "DELETE * FROM PlanksOK"
CurrentDb.Execute (strsql)
strsql = "INSERT INTO PlanksOK(LengthOK) SELECT LengthCM FROM Planks WHERE LengthCM<=200"
CurrentDb.Execute (strsql)
strsql = "SELECT * FROM Planks"
Set stdset = CurrentDb.OpenRecordset(strsql)
With stdset
Do Until LengthCM = 0
LengthCM = !LengthCM
maxlength = 200
If LengthCM > maxlength + 30 Then
strsql = "INSERT INTO PlanksOK(LengthRest1) SELECT LengthCM FROM Planks"
CurrentDb.Execute (strsql)
End If
Exit Do
.MoveNext
.Close
Loop
End With
End Sub