Help with incrementing in subform

G

Geoff

Would someone please be able to tell me how I can change the following code
(part of it kindly provided by Pavel Romashkin in another thread) so that
the dates in field 'day' in my subform always increment my 1 day each time?
The subform and form are linked with the field 'weekstarting'.

There doesn't seem to be a pattern here. Sometimes the date IS incremented
by 1 each time and sometimes each row of the subform shows the same date
(which is the same as the date in 'weekstarting'). If it increments once on
the 2nd row, it will work until all 7 days have been entered. However, if it
doesn't increment for the 2nd row then it doesn't at all, so each row shows
the same date.

It may or may not be relevant that I have the default value for
'weekstarting' in the parent form set to:
=DMax("[weekstarting]","weeks")+7
That's just to add 7 days to each main form record, and that works fine.
Could it be affecting the code below though?

Here is the code I have so far...
-------------
If Me.RecordsetClone.RecordCount = 7 Then
Cancel = True
Else
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Select the record in the main form first."
Else
Me!day = Nz(DMax("day", "days", _
"weekstarting = #" & Me.Parent!weekstarting & "#"), _
Me.Parent!weekstarting - 1) + 1
End If
End If
 

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

Top