PC Review


Reply
Thread Tools Rate Thread

Any sample code to verify data?

 
 
ron
Guest
Posts: n/a
 
      20th Nov 2006
I have an input sheet which received the data from someone else.

All the columns have some restriction, such as one date field must be
greater than another date field, etc.

I need to check the data integrity based on the data rules I have for
each column. If the data is not satisfied, it will pop up some warning
messages, or highlight the cells.

Are there any sample codes that I can borrow?

Appreciate your help greatly,


Ron

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      20th Nov 2006
Given the number of formats people may want to input dates, you will make
your own life more easy if you provide them with a calendar control.
This should get you started :
http://www.google.co.uk/search?hl=en...e+Search&meta=

NickHK

"ron" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have an input sheet which received the data from someone else.
>
> All the columns have some restriction, such as one date field must be
> greater than another date field, etc.
>
> I need to check the data integrity based on the data rules I have for
> each column. If the data is not satisfied, it will pop up some warning
> messages, or highlight the cells.
>
> Are there any sample codes that I can borrow?
>
> Appreciate your help greatly,
>
>
> Ron
>



 
Reply With Quote
 
ron
Guest
Posts: n/a
 
      20th Nov 2006
Nick, thanks for the reponse. It is not just about date. The issue is,
I will receive a sheet and need to verify that all the fields, such as:

one date field needs to be greater than another date field
One text field must be value of "Inv" or blank, but nothing else
One numerical field must be positive number,

etc.

I need to make sure the sheet I received satisfies all the conditions.
Otherwise it will highlight the cells which do not.

thanks,


Ron


NickHK wrote:
> Given the number of formats people may want to input dates, you will make
> your own life more easy if you provide them with a calendar control.
> This should get you started :
> http://www.google.co.uk/search?hl=en...e+Search&meta=
>
> NickHK
>
> "ron" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I have an input sheet which received the data from someone else.
> >
> > All the columns have some restriction, such as one date field must be
> > greater than another date field, etc.
> >
> > I need to check the data integrity based on the data rules I have for
> > each column. If the data is not satisfied, it will pop up some warning
> > messages, or highlight the cells.
> >
> > Are there any sample codes that I can borrow?
> >
> > Appreciate your help greatly,
> >
> >
> > Ron
> >


 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      20th Nov 2006
Sorry, I misread "data" as date in the subject.

You could set up Data>Validation rules on the worksheet.

Or if you wish to use a class module, you would have easier maintenance in
the events that the criteria change; you would have to change only one
place. A brief example below.
You could pass the whole range to the class instead (or an array of values),
improve the criteria detection, input checking that a single cell is passed,
include more properties so it can be configured better, return an error
string or Raise an error upon failure...
Depends how complex you wish to get.

NickHK

<cDataValidation>
Private Const AllowedEntries As String = "Inv, "

Public Function ValidateData(StartCell As Range) As Boolean 'Or String Or
Long
ValidateData = False

With StartCell
If .Value > .Offset(0, 1).Value Then 'Is Date greater the next cell ?
If InStr(.Offset(0, 2).Value, AllowedEntries) > 0 Then 'Is Inv or
blank ?
If .Offset(0, 3).Value >= 0 Then 'Is +ve ?
ValidateData = True
End If
End If
End If
End With

End Function

</cDataValidation>

<Worksheet>
Private Sub cmdValidate_Click()
Dim cell As Range
Dim MyValidation As cDataValidation

Set MyValidation = New cDataValidation

For Each cell In Range("A1:A100")
With MyValidation
If .ValidateData(cell) = False Then MsgBox "Error in row : " &
cell.Address
End With
Next

End Sub
</Worksheet>

"ron" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Nick, thanks for the reponse. It is not just about date. The issue is,
> I will receive a sheet and need to verify that all the fields, such as:
>
> one date field needs to be greater than another date field
> One text field must be value of "Inv" or blank, but nothing else
> One numerical field must be positive number,
>
> etc.
>
> I need to make sure the sheet I received satisfies all the conditions.
> Otherwise it will highlight the cells which do not.
>
> thanks,
>
>
> Ron
>
>
> NickHK wrote:
> > Given the number of formats people may want to input dates, you will

make
> > your own life more easy if you provide them with a calendar control.
> > This should get you started :
> >

http://www.google.co.uk/search?hl=en...e+Search&meta=
> >
> > NickHK
> >
> > "ron" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > I have an input sheet which received the data from someone else.
> > >
> > > All the columns have some restriction, such as one date field must be
> > > greater than another date field, etc.
> > >
> > > I need to check the data integrity based on the data rules I have for
> > > each column. If the data is not satisfied, it will pop up some warning
> > > messages, or highlight the cells.
> > >
> > > Are there any sample codes that I can borrow?
> > >
> > > Appreciate your help greatly,
> > >
> > >
> > > Ron
> > >

>



 
Reply With Quote
 
ron
Guest
Posts: n/a
 
      21st Nov 2006
Thanks so much for your help. It is very informative.




NickHK wrote:
> Sorry, I misread "data" as date in the subject.
>
> You could set up Data>Validation rules on the worksheet.
>
> Or if you wish to use a class module, you would have easier maintenance in
> the events that the criteria change; you would have to change only one
> place. A brief example below.
> You could pass the whole range to the class instead (or an array of values),
> improve the criteria detection, input checking that a single cell is passed,
> include more properties so it can be configured better, return an error
> string or Raise an error upon failure...
> Depends how complex you wish to get.
>
> NickHK
>
> <cDataValidation>
> Private Const AllowedEntries As String = "Inv, "
>
> Public Function ValidateData(StartCell As Range) As Boolean 'Or String Or
> Long
> ValidateData = False
>
> With StartCell
> If .Value > .Offset(0, 1).Value Then 'Is Date greater the next cell ?
> If InStr(.Offset(0, 2).Value, AllowedEntries) > 0 Then 'Is Inv or
> blank ?
> If .Offset(0, 3).Value >= 0 Then 'Is +ve ?
> ValidateData = True
> End If
> End If
> End If
> End With
>
> End Function
>
> </cDataValidation>
>
> <Worksheet>
> Private Sub cmdValidate_Click()
> Dim cell As Range
> Dim MyValidation As cDataValidation
>
> Set MyValidation = New cDataValidation
>
> For Each cell In Range("A1:A100")
> With MyValidation
> If .ValidateData(cell) = False Then MsgBox "Error in row : " &
> cell.Address
> End With
> Next
>
> End Sub
> </Worksheet>
>
> "ron" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Nick, thanks for the reponse. It is not just about date. The issue is,
> > I will receive a sheet and need to verify that all the fields, such as:
> >
> > one date field needs to be greater than another date field
> > One text field must be value of "Inv" or blank, but nothing else
> > One numerical field must be positive number,
> >
> > etc.
> >
> > I need to make sure the sheet I received satisfies all the conditions.
> > Otherwise it will highlight the cells which do not.
> >
> > thanks,
> >
> >
> > Ron
> >
> >
> > NickHK wrote:
> > > Given the number of formats people may want to input dates, you will

> make
> > > your own life more easy if you provide them with a calendar control.
> > > This should get you started :
> > >

> http://www.google.co.uk/search?hl=en...e+Search&meta=
> > >
> > > NickHK
> > >
> > > "ron" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > I have an input sheet which received the data from someone else.
> > > >
> > > > All the columns have some restriction, such as one date field must be
> > > > greater than another date field, etc.
> > > >
> > > > I need to check the data integrity based on the data rules I have for
> > > > each column. If the data is not satisfied, it will pop up some warning
> > > > messages, or highlight the cells.
> > > >
> > > > Are there any sample codes that I can borrow?
> > > >
> > > > Appreciate your help greatly,
> > > >
> > > >
> > > > Ron
> > > >

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample Code Demonstrating How to Populate a Drop Down with Data From an Access DB David C. Holley Microsoft Outlook Discussion 0 5th Jan 2010 01:13 AM
Sample code to make your code reload data that changed in config file delphiconsultingguy@yahoo.com Microsoft Dot NET Framework 0 13th Jun 2006 06:55 PM
Sample Code to Accept form data, then write it to a table =?Utf-8?B?UGF0Sw==?= Microsoft Access Form Coding 4 13th Mar 2006 07:24 PM
Sample Code to Verify Email Addresses Wayne Wengert Microsoft VB .NET 0 6th May 2005 07:01 PM
Import and view external data - sample code? Birte Microsoft Access External Data 1 20th Apr 2004 10:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:50 AM.