G
Geoff
I'm trying to increment the date on my subform by one day each time, and am
having difficulty. I've seen this question asked many times in this group so
sorry for repeating it, but I just cannot get it to work and I am tearing my
hair out with this. If I give my table and field names, would someone please
be kind enough to type out the exact code I need, taking into account my
particular table/field names? I'm not being lazy with this-I just cannot get
it to work so I'm obviously missing something that's probably obvious to
someone who's used to writing code.
The code I have seen in several posts is this (to be put in
Form_BeforeInsert on the Subform):
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Select the record in the main form first."
Else
Me.ID = Nz(DMax("ID", "YourSubFormTable", _
"YourForeignKey = " & Me.Parent.MainID),0) + 1
End If
My main form is linked to a table called 'weeks' and my subform to a query
called 'query-days'. They are linked with the field 'weekstarting' (same
field name in both main form table and subform query). What I want is for
the 'day' field in the first subform record for each main form record to be
the same date as the 'weekstarting' field, and then for 1 to be added each
time.
Any help would be much appreciated. I would imagine it's simply a case of
understanding the code I quoted above properly, but nothing I've tried
works.
Many thanks,
Geoff.
having difficulty. I've seen this question asked many times in this group so
sorry for repeating it, but I just cannot get it to work and I am tearing my
hair out with this. If I give my table and field names, would someone please
be kind enough to type out the exact code I need, taking into account my
particular table/field names? I'm not being lazy with this-I just cannot get
it to work so I'm obviously missing something that's probably obvious to
someone who's used to writing code.
The code I have seen in several posts is this (to be put in
Form_BeforeInsert on the Subform):
If Me.Parent.NewRecord Then
Cancel = True
MsgBox "Select the record in the main form first."
Else
Me.ID = Nz(DMax("ID", "YourSubFormTable", _
"YourForeignKey = " & Me.Parent.MainID),0) + 1
End If
My main form is linked to a table called 'weeks' and my subform to a query
called 'query-days'. They are linked with the field 'weekstarting' (same
field name in both main form table and subform query). What I want is for
the 'day' field in the first subform record for each main form record to be
the same date as the 'weekstarting' field, and then for 1 to be added each
time.
Any help would be much appreciated. I would imagine it's simply a case of
understanding the code I quoted above properly, but nothing I've tried
works.
Many thanks,
Geoff.