Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2004, 05:53 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default Syntax Needed

I'm not getting some syntax correct that should be relatively straightforward. Here it is in English. This code goes in the On Format Event of the detail section. I want to loop through each control in the detail section only.:

Code:
   Dim ctlMyControl as Control

   For Each ctlMyControl In ONLY THE DETAIL SECTION OF THE REPORT
      Blah, blah...
   Next

I tried Me.Detail in that red part, but that won't work. I don't want Me because I want the other sections to be skipped. What am I missing?

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
__________________
Greg Serrano
Michigan Dept. of Environmental Quality
Air Quality Division
 
Old February 5th, 2004, 05:58 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think what you'll need to do is actually omit the controls you don't want to evaluate. Like

   For Each ctlMyControl AND NOT ctlMyControl.name = "firsttoomit" AND NOT ctlMyControl.name = "secondtoomit" then
      Blah, blah...
   Next

HTH,

Beth M
 
Old February 6th, 2004, 06:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
Me.Section(acDetail)
is what you're looking for!


Brian Skelton
Braxis Computer Services Ltd.
 
Old February 6th, 2004, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by Braxis
 
Code:
Me.Section(acDetail)
 Brian, that didn't work. I got an error #438, "Object doesn't support this property or method".

What did ending up working is a variation of Beth's answer. I didn't want to have to specify each unwanted control, however. So I got around that by doing this. I compared ctlMyControl.Section to Me.txtAnotherControl.Section where Me.txtAnotherControl is definitely in the detail section. If ctlMyControl.Section didn't equal Me.txtAnotherControl.Section, I skipped it.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 6th, 2004, 06:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Greg

I think I missed out the
Code:
.controls
bit. Here's how I use it:
Code:
Function SetControlsBlank(objTarget As Object) As Boolean
' Comments  : Set the contents to blank of all the controls in the given section
' Parameters: objTarget - A form section
'           
' Returns   : Boolean - TRUE If successful
' Modified  :
'
' --------------------------------------------------
Dim ctlCtrlCount As Control
On Error GoTo errSetControlsBlank

    For Each ctlCtrlCount In objTarget.Controls
        On Error Resume Next
        'Set check boxes to FALSE all others to NULL
        Select Case ctlCtrlCount.ControlType
            Case acTextBox, acListBox, acComboBox
                ctlCtrlCount.Value = Null
                Err = 0
            Case acCheckBox
                ctlCtrlCount.Value = False
        End Select
    Next ctlCtrlCount

    SetControlsBlank = True

exitSetControlsBlank:
    Exit Function

errSetControlsBlank:
    MsgBox Err.Description & " " & "mdlForms" & ":" & "SetControlsBlank"
    SetControlsBlank = False
    Resume exitSetControlsBlank

End Function
This function is called with
Code:
bolResult = SetControlsBlank(Me.Section(acDetail))

Brian Skelton
Braxis Computer Services Ltd.





Similar Threads
Thread Thread Starter Forum Replies Last Post
help syntax please khautinh SQL Server 2000 1 August 26th, 2006 02:47 AM
c# syntax msrnivas .NET Web Services 2 October 15th, 2004 01:26 AM
Word VBA Syntax Needed SerranoG VB How-To 4 October 28th, 2003 02:16 PM
Procedure Calling Syntax Needed SerranoG Access VBA 4 October 24th, 2003 07:03 AM
SQL syntax for my query - guru needed badgolfer Access 2 September 20th, 2003 01:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.