J
Judy
I am trying to "Do While" based on the number of records on a form.
There is a text box on the form CNT which has a control source
=Count(*). This accurately displays the record count. I then set a
variable Cntr to be equal to the number of records. I had a bunch
more code, but then I realized the cntr was not initializing so i took
everthing else out. I added another test text box to my form (Text22)
to verify that the counter was not initializing. Two odd things: 1) I
use this exact scenario elsewhere and it works fine. 2) If the form is
opened already it works.
I have included my code and would be very grateful for any help.
Thanks. Judy
Private Sub Command48_Click()
Dim Cntr As Integer
DoCmd.OpenForm "frmMYVAr", acNormal, "", "", , acNormal
DoCmd.GoToRecord acForm, "frmMyVar", acFirst
Cntr = Forms![frmMyVar]![CNT]
Forms![frmMyVar]![Text22] = Cntr
Do While Cntr > 0
Forms![frmMyVar]![ActForYtd] = "55"
DoCmd.GoToRecord acForm, "frmMYVar", acNext
Cntr = Cntr - 1
Loop
End Sub
There is a text box on the form CNT which has a control source
=Count(*). This accurately displays the record count. I then set a
variable Cntr to be equal to the number of records. I had a bunch
more code, but then I realized the cntr was not initializing so i took
everthing else out. I added another test text box to my form (Text22)
to verify that the counter was not initializing. Two odd things: 1) I
use this exact scenario elsewhere and it works fine. 2) If the form is
opened already it works.
I have included my code and would be very grateful for any help.
Thanks. Judy
Private Sub Command48_Click()
Dim Cntr As Integer
DoCmd.OpenForm "frmMYVAr", acNormal, "", "", , acNormal
DoCmd.GoToRecord acForm, "frmMyVar", acFirst
Cntr = Forms![frmMyVar]![CNT]
Forms![frmMyVar]![Text22] = Cntr
Do While Cntr > 0
Forms![frmMyVar]![ActForYtd] = "55"
DoCmd.GoToRecord acForm, "frmMYVar", acNext
Cntr = Cntr - 1
Loop
End Sub