Share via

GETTING ERROR

Anonymous
2024-08-09T08:33:29+00:00

HI

I am getting an error when form SLRENF runs. This error pop up at textbox10. I tried but unable to remove. Kindly guide me.

TAX DETAIL.xlsm

thanks.

Microsoft 365 and Office | Excel | For home | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2024-08-09T09:33:34+00:00

You clear all the check boxes in TextBox9_AfterUpdate, including TextBox9 itself.

This causes TextBox9_AfterUpdate to run again, but then the line

m = TextBox10.Value

fails since TextBox10 does not contain a date: it has just been cleared. To avoid this problem:

Private Sub TextBox9_AfterUpdate()
    Dim m As Date
    Dim n As Date
    Dim a, b, c, diff As Integer
    Dim erow As Long
    Static f As Boolean

    If f Then Exit Sub

    a = Me.TextBox3.Value
    b = Me.TextBox4.Value
    m = Me.TextBox10.Value
    n = Me.TextBox9.Value

    diff = DateDiff("d", m, n)
    Me.TextBox11.Value = (diff + 1)
    c = Me.TextBox11.Value

    Me.TextBox6.Value = (c * a * b)
    erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    Cells(erow, 1) = Me.TextBox1.Text
    Cells(erow, 2) = Me.TextBox7.Text
    Cells(erow, 3) = Me.TextBox3.Text
    Cells(erow, 4) = Me.TextBox4.Text
    Cells(erow, 5) = Me.TextBox10.Value
    Cells(erow, 6) = Me.TextBox9.Value
    Cells(erow, 7) = Me.TextBox11.Value
    Cells(erow, 8) = Me.TextBox5.Text
    Cells(erow, 9) = Me.TextBox6.Value

    f = True
    Me.TextBox1.Text = ""
    Me.TextBox7.Text = ""
    Me.TextBox11.Text = ""
    Me.TextBox3.Text = ""
    Me.TextBox4.Text = ""
    Me.TextBox9.Value = ""
    Me.TextBox10.Value = ""
    Me.TextBox5.Text = ""
    Me.TextBox6.Text = ""

    Me.TextBox7.SetFocus

    Me.TextBox1.Value = Sheet1.Range("a1").CurrentRegion.Rows.Count
    f = False
End Sub

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2024-08-09T10:32:49+00:00

    Many thanks Hans....

    Appreciate prompt response.

    Prob solved.

    cheers

    Was this answer helpful?

    0 comments No comments