new things

Hi

I want to add a new label to a form in access during run time, I then want to change the label.
Also I want to add a combo box with the list sourced from an SQL statment.

How do I add controls to a form in run-time? (in access)

I can probably do this in VB6, but with VBA I'm stuck

Cheers

Hadji
--------------------
Ying Tong Iddle I Po - Goons

Comments


  • : I can probably do this in VB6, but with VBA I'm stuck
    Yes, you can do this in VB6. You have to make a control array, so in designing mode, you put in two labels with the same name. Then VB6 will ask you: "Do you want to create a control array?" then you click yes.
    Then in the code of your project, put in this:

    private sub lbl1_Click(index as integer)
    load lbl1(index + 1)
    lbl1(index + 1).top = 2000
    lbl1(index + 1).left = 2000
    lbl1(index + 1).caption = "Hello, I'm a new label"
    end sub

    maybe you need to put lbl1.show in this code, but I don't know, I'm not at home now, so I don't have VB at this computer.
    If you click at lbl1(1) then this program will create a lbl1(2) at position (2000,2000) and with the caption "Hello, I'm a new label".
    Make sure you check out how many of lbl1's there are, then you can put this code for example behind a command button.

    Excuse me for my English, I'm dutch, so I don't speak English very well.

    Hope you have success with this help.

    Greetings,

    VBNert
  • Yes, I said I can do it in VB6, what I need is VBA code.
    Any idea?

    :
    : : I can probably do this in VB6, but with VBA I'm stuck
    : Yes, you can do this in VB6. You have to make a control array, so in designing mode, you put in two labels with the same name. Then VB6 will ask you: "Do you want to create a control array?" then you click yes.
    : Then in the code of your project, put in this:
    :
    : private sub lbl1_Click(index as integer)
    : load lbl1(index + 1)
    : lbl1(index + 1).top = 2000
    : lbl1(index + 1).left = 2000
    : lbl1(index + 1).caption = "Hello, I'm a new label"
    : end sub
    :
    : maybe you need to put lbl1.show in this code, but I don't know, I'm not at home now, so I don't have VB at this computer.
    : If you click at lbl1(1) then this program will create a lbl1(2) at position (2000,2000) and with the caption "Hello, I'm a new label".
    : Make sure you check out how many of lbl1's there are, then you can put this code for example behind a command button.
    :
    : Excuse me for my English, I'm dutch, so I don't speak English very well.
    :
    : Hope you have success with this help.
    :
    : Greetings,
    :
    : VBNert
    :

    ----------------------------------------------------
    The solution to the problem changes the problem

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories