Help saving Value with VBA in a query or form

bessej43

Registered User.
Local time
Today, 02:58
Joined
Jun 12, 2002
Messages
22
This is a follow on to another message, I want to put this value in the table and form. It show in the form but the table still shows the rounding error. Right now I just have it as a Form Load but would like it to perform the calulation for the whole query and not just the form. Thank you for all your help.

Private Sub Form_Load()

'When Form Loads
LoadDefaultValues

End Sub

Private Sub LoadDefaultValues()
Dim NumberOfDays As Single
Dim StartDay As Single
Dim StopDay As Single
StartDay = Day([Start Date])
StopDay = Day([Finish Date])

NumberOfDays = (DateDiff("m", [Start Date], [Finish Date]) - 1) * 2.5


Select Case StartDay
Case Is <= 6
NumberOfDays = NumberOfDays + 2.5
Case Is <= 12
NumberOfDays = NumberOfDays + 2
Case Is <= 18
NumberOfDays = NumberOfDays + 1.5
Case Is <= 24
NumberOfDays = NumberOfDays + 1
Case Is <= 31
NumberOfDays = NumberOfDays + 0.5
End Select

Select Case StopDay
Case Is <= 6
NumberOfDays = NumberOfDays + 0.5
Case Is <= 12
NumberOfDays = NumberOfDays + 1
Case Is <= 18
NumberOfDays = NumberOfDays + 1.5
Case Is <= 24
NumberOfDays = NumberOfDays + 2
Case Is <= 31
NumberOfDays = NumberOfDays + 2.5
End Select

Me![Total Days For Contingency].Value = NumberOfDays
Me.Recordset.Edit
Me.Recordset![Total Days For Contingency].Value = NumberOfDays
Me.Recordset.Add
'Me.Recordset.Update
Command28_Click
 

Users who are viewing this thread

Back
Top Bottom