March 16, 2021 at 7:11 AM #1 sir I'm getting run time error. if i select the to datePlease go through the attached filePlease do help me out sir
March 16, 2021 at 7:47 AM #2 change your code to the following. Code Private Sub TextBox2_Change() Me.TextBox3.Value = CDate(Me.TextBox2.Value) - CDate(Me.TextBox1.Value) Me.TextBox3.Value = Me.TextBox3.Value + 1 End Sub Your code is trying to subtract TextBox3 from TextBox2 which is causing the issue.
March 16, 2021 at 10:14 AM #4 You can also use the VBA DateDiff function Code Private Sub TextBox2_Change() Me.TextBox3.Value = DateDiff("d", CDate(Me.TextBox1.Value), CDate(Me.TextBox2.Value)) End Sub