0

error occurred from "clear Button" there are two field with data type with date& time

Private Sub cmdClear_Click()

    Me.SampleCode = ""
    Me.ReceivedDate = ""
    Me.SampleQuntity = ""
    Me.SampleReceivedTime = ""
    Me.SampleName = ""
    Me.BatchNo = ""
    Me.MRANo = ""
    Me.Division = ""
    Me.SubmittedBy = ""
    Me.ReceivedBy = ""
    Me.AssignedTo = ""

    ''focuse on SampleCode txtBox
    Me.SampleCode.SetFocus

End Sub
4
  • Code cannot be VBA and VB.NET. Please read the description of a tag before adding it. The description of the VB.NET tag SPECIFICALLY states that it should not be used for VBA questions. Commented Jul 13, 2018 at 7:02
  • I am not familiar with VB but Date and Time cannot be empty strings. It must be a method to set them to empty date. Commented Jul 13, 2018 at 7:09
  • Thanks for support
    – K.Badra
    Commented Jul 13, 2018 at 7:11
  • Just tried setting up a database with a table and a form with a button such as yours. Works for me. Can you try to comment out each line of your Clear procedure in turn, to see if it is the date time fields that give the error?
    – ahsoe
    Commented Jul 13, 2018 at 7:16

1 Answer 1

1

Without any further information to go on it's either:

  • Your received date can't accept any empty string.
    If it can't be Null then set it to something like 01-01-1900.

  • Any fields that are numeric should be set to Null or 0.

  • It could be that you've misspelt SampleQuntity. Should it be SampleQuantity?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.