Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 5th, 2004, 05:53 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #2 (permalink)  
Old February 5th, 2004, 05:58 PM
Friend of Wrox
 
Join Date: Jul 2003
Location: Houston, Texas, USA.
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
Reply With Quote
  #3 (permalink)  
Old February 6th, 2004, 06:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oxford, , United Kingdom.
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.
Reply With Quote
  #4 (permalink)  
Old February 6th, 2004, 09:16 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
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
Reply With Quote
  #5 (permalink)  
Old February 6th, 2004, 06:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oxford, , United Kingdom.
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:14 PM.


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