1

If anyone can rewrite this for me I'd really appreciate it. I'm trying to change stored date if null. I've tried Me.vipEndDate ="0000-00-00" and much more.

            If DR("vipEndDate") Is Nothing Then
              Me.vipEndDate = "0"
            Else
              Me.vipEndDate = DR("vipEndDate").ToString
            End If
1
  • I've set it up in database as DATE not DATETIME. Commented Aug 6, 2015 at 0:27

1 Answer 1

1

Well you could add some error protection. The TryParse attempts to convert a string to a date, if it does not convert it returns false so you code will not execute with an error.

Dim dt As Date
If Date.TryParse(DR("vipEndDate").ToString, dt) Then
  'this part only executes if string convert
  Me.vipEndDate = dt
End If
Sign up to request clarification or add additional context in comments.

2 Comments

Wow, that didn't throw any errors. Thanks. Not sure completely what it's doing, can you please explain ? Thanks again,
I like it ! Just starting out and doing well but this caught me out. Won't forget it. Thank you. You have no idea how much you've helped me out this end. :-)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.