Consulting

Results 1 to 5 of 5

Thread: Error when creating control

  1. #1
    VBAX Newbie
    Joined
    Sep 2005
    Posts
    1
    Location

    Error when creating control

    I get an error message when I try to run this...

    Error num: 3799

    Cant find label 'label134'

    When I try to run it on a different form it works fine how come its not working on my form "Articulo". Ill be happy to supply with more info if needed.

    [VBA] Sub NewControls()
    Dim ctlLabel As Control
    Dim intLabelX As Integer, intLabelY As Integer

    DoCmd.OpenForm "Articulo", acDesign
    ' Set positioning values for new controls.
    intLabelX = 1000
    intLabelY = 100
    ' Create child label control for text box.
    Set ctlLabel = CreateControl(Forms!Articulo.Name, acLabel, , , "NewLabel", intLabelX, intLabelY)
    ' Restore form.
    DoCmd.Restore
    DoCmd.OpenForm "Articulo"
    End Sub
    [/VBA]
    Last edited by geekgirlau; 10-03-2005 at 05:05 AM. Reason: Add VBA tags

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Welcome 19701!

    I've edited your post to put VBA tags around your code - you can do this by selecting your text and clicking on the "VBA" button.

    Could you post the CreateControl procedure?

  3. #3
    It looks like CreateControl() is yet another built-in Access function that Microsoft didn't bother to document in their help files... at least in my version of Access 2000, anyway. However, I did finally find the syntax for it. With that in mind, my first two questions are:
    1. Why did you set the ColumnName parameter to "NewLabel"? Even if Articulo's recordset table contained a field by this name, a label cannot be a data-bound control anyway. Does this serve another purpose?
    2. By any chance is your form less than 0.7" wide (1000 twips), or the Detail section less than .07" tall (100 twips)?
    Try omitting all the optional arguments of CreateControl, using just this:
    [VBA]
    Set ctlLabel = CreateControl(Forms!Articulo.Name, acLabel)
    [/VBA]

    If that works, try including the additional parameters one by one to see what causes the error.

  4. #4
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    chocobochick

    CreateControl is documented in Help. I think you would need to goto Access VBA Help to find it, and a lot of other things too.

    CreateControl, CreateReportControl Methods




    • The CreateControl method creates a control on a specified open form.
    • The CreateReportControl method creates a control on a specified open report.
    For example, suppose you are building a custom wizard that allows users to easily construct a particular form. You can use the CreateControl method in your wizard to add the appropriate controls to the form.

    Syntax

    CreateControl(formname, controltype[, section[, parent[, columnname[, left[, top[, width[, height]]]]]]])

    CreateReportControl(reportname, controltype[, section[, parent[, columnname[, left[, top[, width[, height]]]]]]])

  5. #5
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Thanks Norie - haven't had an opportunity to use this one, but yep I did find it when I had a proper look .

    How are you going with this 19701? Have you tried Chocobochick's suggestions?

Posting Permissions

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