L
Lasse T
Hello !!
This is probably a simple one for all you gurus out there.
This code loops thru a continous form and fill the field "fakturanummer"
with "1" added to it for each record starting with the highest value from
the order table +1. Then the user pushes a print button to print invoices.
When the invoice are printed it will never show up in this form again. So
far so good. The trouble starts if the user for some reason closes the form
without pushing the print button. Next time the form are opened the same
orders will come up again and they will get new invoice numbers.
If I could get the loop to only update the field if it is null or zero it
would solve my problem.
Many thanks in advance.
Lasse T
-----------------
Private Sub Form_Load()
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
.Edit
.Fields("Fakturanummer") = DMax("fakturanummer", "order") + 1
.Update
.MoveNext
Loop
End If
End With
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
.Edit
![Fakturadatum] = Date
.Update
.MoveNext
Loop
End If
End With
End Sub
This is probably a simple one for all you gurus out there.
This code loops thru a continous form and fill the field "fakturanummer"
with "1" added to it for each record starting with the highest value from
the order table +1. Then the user pushes a print button to print invoices.
When the invoice are printed it will never show up in this form again. So
far so good. The trouble starts if the user for some reason closes the form
without pushing the print button. Next time the form are opened the same
orders will come up again and they will get new invoice numbers.
If I could get the loop to only update the field if it is null or zero it
would solve my problem.
Many thanks in advance.
Lasse T
-----------------
Private Sub Form_Load()
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
.Edit
.Fields("Fakturanummer") = DMax("fakturanummer", "order") + 1
.Update
.MoveNext
Loop
End If
End With
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
.Edit
![Fakturadatum] = Date
.Update
.MoveNext
Loop
End If
End With
End Sub