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 / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

Testing For Presence of a Section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sprinks - 22 Jul 2005 20:39 GMT
In looping through the Forms collection,changing the names of several control
names in the FormHeader, I triggered an error on a form that doesn't have
one.  How can I test for this?

Thank you.
Sprinks
'69 Camaro - 22 Jul 2005 23:07 GMT
Hi, Kevin.

> I triggered an error on a form that doesn't have
> one.  How can I test for this?

Trap for error #2462 in your error handler, and then add appropriate logic
for skipping that section of the Form.  Here's an example:

'  * * * * Start Code * * * *

Public Function fixForm(srcFrm As Form) As Boolean

   On Error GoTo ErrHandler

   Dim sSectName As String
   Dim nInvalidSection As Long
   Dim idx As Long
   Dim fSuccess As Boolean

   Const MAX_SECTION As Long = 4

   nInvalidSection = 0                                     ' Init.

   For idx = 0 To MAX_SECTION
       sSectName = srcFrm.Section(idx).Name     ' Check whether section is
valid.

       
'--------------------------------------------------------------------------------
       '  Determine whether the current section being checked isn't in the
       ' source form.
       
'--------------------------------------------------------------------------------
       
       If (nInvalidSection > 0) Then                     ' Must have
"Detail" section = 0.
           nInvalidSection = 0                              '  Reset.

           '  Do whatever.
       End If
   Next idx

   fSuccess = True

CleanUp:

   fixForm = fSuccess

   Exit Function
   
ErrHandler:
   
   If (Err.Number = 2462) Then            ' Section # invalid.
       nInvalidSection = idx
       Err.Clear
       Resume Next
   Else
       MsgBox "Error in fixForm( ) in " & Application.CurrentObjectName & _
               " module." & vbCrLf & vbCrLf & "Error #" & _
               Err.Number & vbCrLf & vbCrLf & Err.Description
       Err.Clear
       fSuccess = False
       GoTo CleanUp
   End If

End Sub

'  * * * * End Code * * * *

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses:  known newsgroup E-mail harvesters
for spammers are Ripley@CASInternet.Net and scott@ripleysoftware.com

- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions.  Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.

> In looping through the Forms collection,changing the names of several control
> names in the FormHeader, I triggered an error on a form that doesn't have
> one.  How can I test for this?
>
> Thank you.
> Sprinks
Sprinks - 23 Jul 2005 04:17 GMT
Thanks, '69.  Another arrow in the quiver.

But won't you tell me how you know my name?  I don't deny it; but I'm just
curious.

Best regards.

Sprinks

> Hi, Kevin.
>
[quoted text clipped - 91 lines]
> > Thank you.
> > Sprinks
Ofer - 24 Jul 2005 09:51 GMT
In your previous posts you use to sign
Kevin Sprinkel

> Thanks, '69.  Another arrow in the quiver.
>
[quoted text clipped - 100 lines]
> > > Thank you.
> > > Sprinks
 
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.