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 / December 2005

Tip: Looking for answers? Try searching our database.

Validation Rule Code Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vmf - 20 Dec 2005 21:38 GMT
I am using the following code in my form but it isn't producing a message box
when tabbing to a new record.  I think the problem might be with the "And"
but I'm not sure.  Any help would be appreciated.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String

   If Me.Combo36 = "P" And IsNull(Me.BegSeqNum) Then
       Cancel = True
       strMsg = strMsg & "Beginning Sequence Number required." & vbCrLf
   End If

   If Me.BegSeqNum > 0 And IsNull(Me.EndSeqNum) Then
       Cancel = True
       strMsg = strMsg & "End Sequence Number required." & vbCrLf
   End If

       If Cancel Then
       strMsg = strMsg & "Correct the entry, or press Esc to undo."
       MsgBox strMsg, vbExclamation, "Invalid data"
   End If

End Sub
Signature

Thank you,
vmf

Marshall Barton - 20 Dec 2005 22:34 GMT
>I am using the following code in my form but it isn't producing a message box
>when tabbing to a new record.  I think the problem might be with the "And"
[quoted text clipped - 18 lines]
>    End If
>End Sub

Unless you want to check for other kinds on invalid entries,
there isn't anything obviously wrong with your code.  Try
placing a breakpoint in there to verify the values of the
two controls.

Signature

Marsh
MVP [MS Access]

vmf - 20 Dec 2005 23:05 GMT
Thank you Mr. Barton, but could you tell me what a breakpoint is & how to
include it in my code?
Signature

Thank you,
vmf

> >I am using the following code in my form but it isn't producing a message box
> >when tabbing to a new record.  I think the problem might be with the "And"
[quoted text clipped - 23 lines]
> placing a breakpoint in there to verify the values of the
> two controls.
Marshall Barton - 21 Dec 2005 01:08 GMT
>Thank you Mr. Barton, but could you tell me what a breakpoint is & how to
>include it in my code?

Open your form in design view.  Then use the View - Code
menu item to see the form's code in the VBA window.  Click
in the left margin gray area next to the line where you want
Access to stop processing (the line should be highlighted
probably in dark red).

Then go back to your form and change it to form view.  Enter
whatever data you need to trigger the code and when it stops
at the selected line, you can see the value of the controls
just by hovering the mouse over the name in the code.  Check
the combo box to make sure it contains a "P", etc.

IMPORTANT - Do not edit the code while the form is displayed
in form view.  Change the form to design view before editing
any code.

Signature

Marsh
MVP [MS Access]

 
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.