Help with loop

L

Lasse T

Hello.
Can anyone se what is wrong? I try to update "fakturanummer" (= invoice
number) in a continous form. The highest number in the table right now is
1000 and there is 8 posts in the form. The loop runs eight times but all in
the first post of the form. It counts up from 1001 to 1008 in the first post
of the form and do nothing in the rest.

Private Sub Kommandoknapp32_Click()
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
.Edit
Me!Faktnr = DMax("fakturanummer", "order") + 1
.Update
.MoveNext
Loop
End If
End With

End Sub

Thanks in advance.

Lasse T
--------------
 
S

Sandra Daigle

Your update is being applied to the current record in the form (me!Faktnr)
rather than the record accessed by the recordsetclone (which would be
..fields("Faktnr"))

Change the line after .Edit to:
.fields("Faktnr") = DMax("fakturanummer", "order") + 1

or to
!Faktnr = DMax("fakturanummer", "order") + 1
 
L

Lasse T

Yesss !!!!

Thank you so much. Works perfect.

Lasse T
-------------

Sandra Daigle said:
Your update is being applied to the current record in the form (me!Faktnr)
rather than the record accessed by the recordsetclone (which would be
.fields("Faktnr"))

Change the line after .Edit to:
.fields("Faktnr") = DMax("fakturanummer", "order") + 1

or to
!Faktnr = DMax("fakturanummer", "order") + 1

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Lasse said:
Hello.
Can anyone se what is wrong? I try to update "fakturanummer" (= invoice
number) in a continous form. The highest number in the table right now is
1000 and there is 8 posts in the form. The loop runs eight times but all
in the first post of the form. It counts up from 1001 to 1008 in the
first post of the form and do nothing in the rest.

Private Sub Kommandoknapp32_Click()
With Me.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
.Edit
Me!Faktnr = DMax("fakturanummer", "order") + 1
.Update
.MoveNext
Loop
End If
End With

End Sub

Thanks in advance.

Lasse T
--------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top