L
Leslie Isaacs
Hello All
I have a form that opens in Continuous Forms view. In the detail section is
a textbox called [stmt_datee], and in the form header is a textbox called
[recs] with control source =Count([ID1]) (ID1 is the key field from the
underlying table, so [recs] is a reliable count of the number of records
being displayed - which the user will regularly alter by various filtering).
I want to create a button that the user can click to set the value of
[stmt_datee] for each of the currently displayed records. I have come up
with the code below, but this doesn't work: sometimes it just sets the
[stmt_datee] value in the first record, and sometimes I get a "Cannot go to
the specified record" message - even when there are, say, 4 records
displayed.
I can't for the life of me see what I've done wrong: any help would be very
much appreciated!!
Thanks
Leslie Isaacs
My code:
Private Sub Command37_click()
Dim sdate As Date
Dim inc As Integer
sdate = InputBox("Enter statement date")
DoCmd.GoToRecord , , acFirst
[stmt_datee].Value = sdate
For inc = 1 To [recs].Value - 1
DoCmd.GoToRecord , , acNext
[stmt_datee].Value = sdate
Next inc
End Sub
I have a form that opens in Continuous Forms view. In the detail section is
a textbox called [stmt_datee], and in the form header is a textbox called
[recs] with control source =Count([ID1]) (ID1 is the key field from the
underlying table, so [recs] is a reliable count of the number of records
being displayed - which the user will regularly alter by various filtering).
I want to create a button that the user can click to set the value of
[stmt_datee] for each of the currently displayed records. I have come up
with the code below, but this doesn't work: sometimes it just sets the
[stmt_datee] value in the first record, and sometimes I get a "Cannot go to
the specified record" message - even when there are, say, 4 records
displayed.
I can't for the life of me see what I've done wrong: any help would be very
much appreciated!!
Thanks
Leslie Isaacs
My code:
Private Sub Command37_click()
Dim sdate As Date
Dim inc As Integer
sdate = InputBox("Enter statement date")
DoCmd.GoToRecord , , acFirst
[stmt_datee].Value = sdate
For inc = 1 To [recs].Value - 1
DoCmd.GoToRecord , , acNext
[stmt_datee].Value = sdate
Next inc
End Sub