[AccessD] Several Questions regarding versions

Heenan, Lambert Lambert.Heenan at chartisinsurance.com
Thu Nov 12 10:32:37 CST 2009


Arthur,
 
Regarding the exclamation point.

The code reads...
    With Forms(m_sFormName)
        !sfcWizPanel.SourceObject = arrPanels(m_nCurrentPanel - 1).sSubForm
      'and more similar statements
     ' and with conclude with ...
    End With

The With/End With construct allows you to work with the members of structured data, be they typdefs or recordsets or whatever without constantly typing the name of the container object.

For example, given

Type MyType
    nNumber as Long
    strString  as Long
End Type

You can then declare a variable

Dim SomeData As MyType

And then in code ou can write, 

SomeData.nNumber = 1234
SomeDat.strString = "Hello World"

Or you can write
	
With SomeData
	.nNumber = 1234
	.strString = "Hello World"
End With

This is not just a case of saving typing. When using recordset objects, if the recordset name is used in each code statement I think I read that the recordset will be refreshed, which can be time consuming.

Here's a typical example of how I often use With/End With: a search routine. In the after update code of a combo I would write

	With Me.RecordSetClone
		.FindFirst   "SomeField=" & SomeComboBox
		If Not .NoMatch Then
			Me.BookMark = .BookMark
		End If
	End With

The .FindFirst, .NoMatch and .BookMark references are all methods of the RecordsetClone recordset object.

In the case of your example of come code behind a form the form is being accessed

    With Forms(m_sFormName) 
        !sfcWizPanel.SourceObject = arrPanels(m_nCurrentPanel - 1).sSubForm

And so "sfcWizPanel" is some control on the form which has a SourceObject property, and it is being modified. In this case I think either a period (.) or exclamation point (or "bang") (!) would be syntactically correct. Usually the bang is used if data elements (properties) of an object are referenced, and you use the dot for object methods.

HTH

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller
Sent: Thursday, November 12, 2009 9:15 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Several Questions regarding versions

Questions for AccessD

1. What changed from version 2002 to 2003? I've been using 2003 for so long that I can't remember 2002. As I recall it was buggy so they hurried out a fix that was called 2003. Can anyone confirm or deny? What's in 2003 that is not in 2002? (The reason for this question is that I'm up for an interview for a contract and the client specified 2002 experience. I can't think of a single person that uses 2002.) 2. Are there any tutorials available for how to customize the 2007 ribbon? I think it's been asked and answered but I forget the answer. Has anyone found a way to programmatically turn off the ribbon?
3. Perusing some interesting Access 2007 code for a wizard builder, I came across the following syntax:
    With Forms(m_sFormName)
        !sfcWizPanel.SourceObject = arrPanels(m_nCurrentPanel - 1).sSubForm
      'and more similar statements
I've never seen a line of code that begins with an exclamation point before.
It appears to be no different than a dot. Is it used because of the subsequent dot notation on the remainder of the line?
4. All the 2007 samples are written with macros not code. But when in Design mode on a form, on the Database Tools ribbon tab there is a command to turn all the macros on a form into VBA code. It works like a charm, so I've converted all the samples to VBA code. My question: was this ability always there (i.e. in 2003) and I simply didn't ever notice it, or is it new to 2007?

Thanks in advance.
Arthur
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list