Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

To get a error MsgBox to appear

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 24 May 2007 01:15 GMT
If you enter something other than a number , I want a message box to
apperar:
MsgBox "You Must enter a number from 0-100", vbApplicationModal +
vbInformation + vbOKOnly
Thanks for any help with this.......Bob

Private Sub tbOwnerPercent_AfterUpdate()
   If Len([tbOwnerPercent]) = 0 Then
       Exit Sub
   End If
   tbOwnerPercent.value = CSng(val(tbOwnerPercent.value) / 100)
End Sub
Graham Mandeno - 24 May 2007 04:12 GMT
Hi Bob

The BeforeUpdate event is the best for validating data input:

Private Sub tbOwnerPercent_BeforeUpdate(Cancel As Integer)
   If not IsNumeric(tbOwnerPercent) Then
       Cancel = true
   ElseIf (tbOwnerPercent<1 or tbOwnerPercent>100) _
           and (tbOwnerPercent<>0) Then
       Cancel = true
   End If
   If cancel <> 0 then
       MsgBox "You Must enter a number from 1-100, or 0", vbInformation
   End If
End Sub

Signature

Good Luck  :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

> If you enter something other than a number , I want a message box to
> apperar:
[quoted text clipped - 8 lines]
>    tbOwnerPercent.value = CSng(val(tbOwnerPercent.value) / 100)
> End Sub
Maurice - 24 May 2007 16:27 GMT
Or if it's a bound field you could enter Data validation on table level..
Signature

Maurice Ausum

> Hi Bob
>
[quoted text clipped - 24 lines]
> >    tbOwnerPercent.value = CSng(val(tbOwnerPercent.value) / 100)
> > End Sub
Bob - 26 May 2007 00:31 GMT
Thanks Graham , Good to know none of my owners are going to have a Blank
percent in a Horse ;) ....Bob
> Hi Bob
>
[quoted text clipped - 24 lines]
>>    tbOwnerPercent.value = CSng(val(tbOwnerPercent.value) / 100)
>> End Sub
Bob - 26 May 2007 00:33 GMT
Have something on Sand Hawk next Saturday ellerslie....Bob

> Hi Bob
>
[quoted text clipped - 24 lines]
>>    tbOwnerPercent.value = CSng(val(tbOwnerPercent.value) / 100)
>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.