Results 1 to 5 of 5

Thread: view all command buttons in a project via a combo box

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Location
    uk
    Posts
    13

    view all command buttons in a project via a combo box

    hi all
    i would be greatefull of anyone can help me out basically i want to create a vb front end linked to access database and create a menu in the vb front end of products listed in the database, currently i am using all access database with tab contol to section out the menu ie meat, chicken etc and within each tab i have created buttons for the products this good and works fine only prob is that if another product needs to be added then u have to go into design view create the command button and code it ie
    [Form_OrderDetails subform].Item = Form_Orders.Command4.Caption
    [Form_OrderDetails subform].Amount = 2.8
    newrec
    etc
    i am looking to make a front end vb app and am thinking of having a form whereby i ave already allocated a load of command buttons on each tab but are hidden then with s sepearte form al have a text box1, txtbox 2 a combo box and a command button then i would like to click on the command button (AT run time) and the button would select the comand button from the combo box the buttons caption would become what ever i type in text 1 and etc
    ps. am sorry if it sounds confusing. lol
    i would be greatfull if anyone can help or if any ideas on creating a better menu form using sstab in vb. by the way i will be suing a touchscreen thats the reason for command buttons as products
    thank you

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: view all command buttons in a project via a combo box

    Welcome to the forums!

    Yes... it's a bit confusing... i'm going straightly to the title
    VB Code:
    1. Dim f As Form
    2. Dim c As Control
    3.     For Each f In Forms
    4.         For Each c In f.Controls
    5.             If TypeOf c Is CommandButton Then
    6.                 Combo1.AddItem f.Name & ":" & c.Caption
    7.             End If
    8.         Next
    9.     Next
    This will work only for already loaded Forms.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Location
    uk
    Posts
    13

    Re: view all command buttons in a project via a combo box

    hi thanx gavio for the reply
    tried your code and wow yep it does work only prob is my sstab will be on form1 how will the user knw where which sstab caption the invisible button is on also from the edit form2 what code would i be able to update the hidden button.

    also in your opinion do u think this would be the best way do make a menu system or do u know of anybetter way of doing this i could have used a combo box and display all my products from the access database into the combo box but you could imagine it would be difficult searching through 2 -300 houndered products heres a screen shot example
    [ /IMG]
    Attached Images Attached Images  

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: view all command buttons in a project via a combo box

    as this is for a touch screen, maybe create an array of commandbuttons then you can load those from the database as required
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2006
    Location
    uk
    Posts
    13

    Re: view all command buttons in a project via a combo box

    hi
    thanx westconn1 for the reply your answer sounds interesting and may be what i am looking for only thing is i dnt know really how to go about doing this do you have similar examples i could maybe have a look at, also say the array of command buttons will be based on products would it also be possible to add or delete certain products/command buttons from the vb front end during run time as i wish to create an exe for the front end??

Posting Permissions

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



Click Here to Expand Forum to Full Width