Solved

How to compare DataSet value to a Date enter.

Posted on 2011-02-10
2
373 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now