I am setting up a docketing form for our law office. When we have a multi-day event, such as a trial, I would like to use tags on the controls to carry forward the values for that event, adding one day to the start date, until the start date equals the end date. There are four controls on the form: txtStartDate, txtEndDate, txtEvent and txtPersonnel. Two problems: 1st, the newly-made record won't save until I've made some change in the body of one of the text boxes (kind of defeats the automation purpose); 2nd, I don't know how to set the loop to get it to add 1 record for each new day of the event, rather than just looping through and creating one new record where the start date equals the end date (although this problem may be occurring because of problem 1, if you get my drift). Here is the code WITHOUT the loop set:
Dim ctl As Control
If IsNull(Me!txtEndDate) = False Then
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Carry" Then
ctl.DefaultValue = """" & ctl.Value & """"
End If
Next
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "CarryOne" Then
ctl.DefaultValue = """" & DateAdd("d", 1, txtStartDate) & """"
End If
Next
End If
Where have I gone wrong?
Dim ctl As Control
If IsNull(Me!txtEndDate) = False Then
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Carry" Then
ctl.DefaultValue = """" & ctl.Value & """"
End If
Next
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "CarryOne" Then
ctl.DefaultValue = """" & DateAdd("d", 1, txtStartDate) & """"
End If
Next
End If
Where have I gone wrong?