?
Solved

How to compare DataSet value to a Date enter.

Posted on 2011-02-10
2
Medium Priority
?
384 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
skipper68 earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

765 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