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 / Forms Programming / March 2007

Tip: Looking for answers? Try searching our database.

Form Validation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hughess7 - 29 Mar 2007 12:44 GMT
I have tried using this code on my form to trap Required fields being left
empty. It does not work properly though, it is a continuous form - could this
cause a problem?

Three of my text boxes have a Tag of Reqd, values for them have to be
entered before a record can be saved. Even if I fill in all three fields
though I can not save the record, it prompts with the 'Value Required' text?

Thanks
Sue

Dim ctl As Control

For Each ctl In Me.Section(0).Controls

   If ctl.Tag = "Reqd" Then
       If Len(Trim(Nz(ctl, vbNullString))) Then
           MsgBox ctl.name & " Requires A Value", vbExclamation + vbOKOnly
           Cancel = True
           ctl.SetFocus
           Exit For
       End If
   End If

Next
Ofer Cohen - 29 Mar 2007 13:08 GMT
You need the criteria for the Len = 0

If Len(Trim(Nz(ctl, vbNullString))) = 0 Then

Signature

Good Luck
BS"D

> I have tried using this code on my form to trap Required fields being left
> empty. It does not work properly though, it is a continuous form - could this
[quoted text clipped - 21 lines]
>
> Next
hughess7 - 29 Mar 2007 13:32 GMT
Excellent thanks that did the trick ;-). Sorry, copied code from another
example which had that bit missing.

Thanks again
Sue

> You need the criteria for the Len = 0
>
[quoted text clipped - 25 lines]
> >
> > Next
 
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.