Solved

How to compare DataSet value to a Date enter.

Posted on 2011-02-10
2
379 Views
Last Modified: 2012-05-11
How do I compare Date enterd to a DataSet in the code below:
'Warn user if the Posted entered is a future date.
        If UtilityClass.UnmaskDate(Me.fPostedDate.Text) = Nothing Then
            'nothing to check, bail out
            Exit Sub
        End If
'Error Here
        Select Case (UtilityClass.UnmaskDate(Me.fPostedDate.Text) = Format(PaymentsDataSet.Tables(0).Rows(I).Item("PostedDate"), "MM/dd/yy"))
            Case False
                Exit Sub
            Case True
                Select Case LastNewFinRecord
                    Case 0
                        ' there is not a new finance record id yet. leave it alone
                    Case CInt(Me.fFinRecID.Text)
                        If UtilityClass.UnmaskDate(Me.fPostedDate.Text) = Nothing Then
                            'nothing to check, bail out
                            Exit Sub
                        Else
                            ' Is the Posted Date greater than Today.
                            If (DateTime.Parse(UtilityClass.UnmaskDate(Me.fPostedDate.Text))) > DateTime.Parse(UtilityClass.UnmaskDate(Today)) Then
                                Select Case MessageBox.Show("This Date is in the FUTURE" & vbCrLf & "Is that correct.", "Incorrect Posted Date", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation)
                                    Case vbYes
                                        Me.fPostMarkDate.Focus()
                                    Case vbNo
                                        Me.fPostedDate.Focus()
                                End Select
                            End If
                        End If
                    Case Else
                End Select
        End Select

Open in new window

I get Arguement expression is not valid value.
0
Comment
Question by:pelon_80
2 Comments
 
LVL 9

Accepted Solution

by:
skipper68 earned 500 total points
ID: 34867454
It appears that there may be some values that are "null" (empty). What would you like to do with them?  To confirm, you can display a message box before the line it's failing on to determine this.

If there are nulls in the data, then you should check to see if it is = DBNull.Value before you try to use it in any function or before casting them ( CInt () ).

if Me.xx.Text <> DBNull.Value Then
     'Do Something
else
     'Do Something Else
End If

0
 

Author Closing Comment

by:pelon_80
ID: 34871682
Great! Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question