Results 1 to 3 of 3

Thread: .Caption (A2K)

  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .Caption (A2K)

    In the following code I normally use the first method: .lblHeading.Caption = "Products with a Unit Price "

    But I recently saw an example in Rick Dobson's book programming MS Access 2000 with it in this format:. Controls("lblHeading").Caption = "Products with a Unit Price "

    Is either, better? More or less correct, or is it a case of personal preference?

    DoCmd.OpenReport "rptOne", acViewDesign
    With Reports("rptOne")
    .Visible = False
    .RecordSource = fBuildSQLString

    .lblHeading.Caption = "Products with a Unit Price "
    .Controls("lblHeading").Caption = "Products with a Unit Price "

    End With

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: .Caption (A2K)

    It depends on what the rest of your code looks like and how dependent you are on intellisense when writing your code. Your original construction allows you to select the control from the intellisense dropdown, which Dobson's doesn't. In tests someone ran on another list, they determined that the ("controlname") construction is marginally faster in a large number of transactions, but it probably won't be noticeable whichever method you use. The one place where you have to use the ("controlname") construction is when you're passing in a string variable to specify the controlname instead of using a hard coded string. Otherwise, it's more a matter of style than anything, but you never really have to specify the Controls method, since it's the default anyhow, unless you're doing it inside a With-End With.
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: .Caption (A2K)

    Thanks Charlotte. I'm a little wiser now, (I think)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •