Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataset Question

Status
Not open for further replies.

marcusmco

IS-IT--Management
Oct 9, 2006
30
AU
Hello,

I have a form designed in VS 2005 using vb.net. The controls on this form are bound to a dataset.

When a user keys in something that is not valid according to the data type, e.g. "Dog" where it is supposed to be a number, the keyed in data is simply ignored. This is good since there is no need to check the input using code but sometimes the user doesn't notice that the value he/she keyed in was ignored. My questions is if there is an event that is triggered when this happens so I can display a message on the screen and inform the user.

Regards,
Marcus
 
I think this would work:

Code:
If not isNumeric(entered text variable) then
    msgbox("Entry must be numeric")
end if
 
Yes, that would work but it means that I have to write code for every control on the form and check lots of different combinations. I am trying to avoid that of obvious reasons. :)

If the dataset does not like the data that is keyed it reverts back to the previous value for the control in question. I am hoping that an event is raised when this happens that I can add some code to but I can't find it...
 
If you want good programming, you are going to have to put some controls in your application. Here's an example of a error catching method:
Try
Me.bindWeekly.EndEdit()
Me.WeekEarningsTableAdapter.Update(Me.TimeCardDataSet.WeekEarnings)
Total_Hours_on_Rows()
Catch ex As Exception
strMsg = "The Plant column cannot be blank. Enter the Plant and hit Apply again."
frmDialOK.lblMsg.Text = strMsg
With frmDialOK
.ShowDialog()
End With
End Try

This pops up a information box advising the user of the problem.

Cathy
 
You can also use the errorprovider object to help with data validation and warning messages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top