VBA Error

majid.pervaiz

Registered User.
Local time
Today, 14:16
Joined
Oct 15, 2012
Messages
110
Dear Friends,

I am really in deep shit and need your help to fix error. Actually I am calculating difference between 2 date/time excluding working hours and weekends. Working hours (7:15 am until 2:30 pm), for example if user enter start time 22/06/2016 13:30 pm and end time is 23/06/2016 07:30 am, the total time take should be 75 minutes. Unfortunately some error such as null or invalid field kind of errors I am receiving.

I humbly request you all to help me on this one thing.

I have attached for your reference screenshot and sample database also
 

Attachments

  • code error.jpg
    code error.jpg
    85.9 KB · Views: 95
  • code error2.jpg
    code error2.jpg
    83 KB · Views: 88
  • New Picture.jpg
    New Picture.jpg
    84.8 KB · Views: 96
  • OLA.accdb
    OLA.accdb
    552 KB · Views: 90
change this Sub to:
Code:
Private Sub GetDuration()
    If Not Trim(Me.TxtTimeLower & "") <> "" And Trim(Me.TxtTimeUpper & "")<>"" Then
        Me.TxtDuration = NetWorkhours(Me.TxtTimeLower, Me.TxtTimeUpper, Me.ChkSpell)
    End If
End Sub
 
Dear Based on the above suggested code I tried but now the total time taken is not showing any output
 
sorry for that remove the Not in the sub:

Private Sub GetDuration()
If Trim(Me.TxtTimeLower & "") <> "" And Trim(Me.TxtTimeUpper & "") <> "" Then
Me.TxtDuration = NetWorkhours(Me.TxtTimeLower, Me.TxtTimeUpper, Me.ChkSpell)
End If
End Sub
 
you can't use the SpellOut on this:

Me.TxtDuration = NetWorkhours(Me.TxtTimeLower, Me.TxtTimeUpper, Me.ChkSpell)

since TxtDuration is bound to a field (numeric) in a table.
assigning string to this textbox control will result in error, since the bound field is numeric.
 
Man I am really grateful to you for your help on this. I may bother you again for some other things since I am new in using access but I am trying my best.
 

Users who are viewing this thread

Back
Top Bottom