FreshCoder
Registered User.
- Local time
- Today, 13:29
- Joined
- Sep 22, 2018
- Messages
- 33
Hi again
Ive been strugling to make this through but i miss out the indents....
Can someone plz help me out correcting ?
Thanks

Ive been strugling to make this through but i miss out the indents....
Can someone plz help me out correcting ?
Thanks
Code:
Option Compare Database
Option Explicit
Private lengde As Integer
Private Sub comBeregn_Click()
Dim strsql As String
Dim stdset As DAO.Recordset
Dim max As Integer
Dim min As Integer
Dim rest As Integer
strsql = "DELETE * FROM ListerOK"
CurrentDb.Execute (strsql)
strsql = "INSERT INTO ListerOK (lengde2) SELECT lengde FROM Lister WHERE lengde <= 200"
CurrentDb.Execute (strsql)
If txtMax <> "" Then
max = txtMax
Else
max = 200
End If
If txtMin <> "" Then
min = txtMin
Else
min = 30
End If
strsql = "SELECT * FROM Lister"
Set stdset = CurrentDb.OpenRecordset(strsql)
With stdset
Do While Not .EOF
If !lengde >= min And !lengde <= max Then
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & lengde & ")"
CurrentDb.Execute (strsql)
ElseIf !lengde > max + min Then
rest = !lengde - max
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & max & ")"
CurrentDb.Execute (strsql)
Do While rest <> 0
If rest > max + min Then
rest = rest - max
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & max & ")"
CurrentDb.Execute (strsql)
ElseIf rest >= min And rest <= max Then
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & rest & ")"
CurrentDb.Execute (strsql)
rest = 0
ElseIf rest < max + min And rest > max Then
rest = rest - min
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & min + rest & ")"
CurrentDb.Execute (strsql)
rest = 0
End If
Loop
ElseIf !lengde < max + min And !lengde > max Then
rest = !lengde - min
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & min & ")"
CurrentDb.Execute (strsql)
strsql = "INSERT INTO ListerOK (lengde2) VALUES (" & rest & ")"
CurrentDb.Execute (strsql)
rest = 0
ElseIf !lengde < min Then
End If
.MoveNext
Loop
.Close
End With
DoCmd.OpenTable "ListerOK", acViewNormal
End Sub