Results 1 to 17 of 17

Thread: changing combo1.text on runtime

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    changing combo1.text on runtime

    combo1.text = text1.text doesn't work in the code attached.


    I mean if i put combo1.text = text1.text in a command button by itself, it'll change the text, but check the code and you will see what i'm talking about... it's a bit hard to explain.


    this is the problem i'm having in the software:

    VB Code:
    1. Text1.Text = fsave
    2. Combo1.Text = Text1.Text 'PROBLEM HERE, combo won't show the text
    Attached Files Attached Files
    Last edited by Whatupdoc; Apr 16th, 2006 at 02:40 AM.

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: changing combo1.text on runtime

    Worked fine for me. Maybe you need to give it time to change the text or something so try adding a doevents after "Text1.Text = fsave"

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: changing combo1.text on runtime

    hmm that doevent didn't work either

  4. #4
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: changing combo1.text on runtime

    Stupid to ask but how about
    Combo1.Text = fsave

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: changing combo1.text on runtime

    yea i tried that already, didnt work either. That's why im coming up with all sort of stuff to try to fix it.

    it's really though cause if i put "Combo1.Text = Text1.Text" in a command button alone, it'll work perfectly...

  6. #6
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: changing combo1.text on runtime

    Do you get any errors or anything or does it just not change?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: changing combo1.text on runtime

    no errors, the text on the combo just clears.

  8. #8
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: changing combo1.text on runtime

    Well just a small change. Also i figured out that the time that text changes to "" is at the "Exit Sub" or "End Sub"

    CommonDialog1.Filter = ".txt|*.txt"

    I am now determined to solve this thing

  9. #9
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: changing combo1.text on runtime

    Would this work?

    VB Code:
    1. Dim ChgCmb As Boolean
    2. Private Sub Combo1_Click()
    3.     If ChgCmb Then Exit Sub
    4.     Dim fsave As String
    5.    
    6.     CommonDialog1.Filter = ".txt"     'this sets what filestypes can be saved
    7.     CommonDialog1.DialogTitle = "Please select the list you want to use"
    8.     CommonDialog1.InitDir = App.Path
    9.     CommonDialog1.ShowOpen           'shows "Open Dialog Box"
    10.     fsave = CommonDialog1.FileName   'the file the user selected is "FSave"
    11.    
    12.     If Len(fsave) < 2 Then
    13.     MsgBox "Please Select a File!", vbCritical
    14.     Exit Sub
    15.     End If
    16.    
    17.     ChgCmb = True
    18.     Text1.Text = fsave
    19.     Combo1.AddItem Text1.Text, 0
    20.     Combo1.ListIndex = Combo1.NewIndex
    21.     ChgCmb = False
    22. End Sub

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: changing combo1.text on runtime

    I don't really want to add the item into the combo, but if all else fails I'll have to do that. Thanks for the code

  11. #11
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: changing combo1.text on runtime

    Sorry i wasn't much help

  12. #12
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: changing combo1.text on runtime

    is it resolved....
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  13. #13
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: changing combo1.text on runtime

    did u try the .listindex property method ??
    __________________
    ________________0îîî___
    ___îîî0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

  14. #14
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: changing combo1.text on runtime

    if you want to be able to save the text you must change the combo's Style property to 0 - Dropdown Combo, i'm guessing you have it currently set to 2 - Dropdown List
    Chris

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: changing combo1.text on runtime

    Quote Originally Posted by the182guy
    if you want to be able to save the text you must change the combo's Style property to 0 - Dropdown Combo, i'm guessing you have it currently set to 2 - Dropdown List
    Nope, i had it set to 0 - Dropdown combo (default)


    did u try the .listindex property method ??
    what do you mean? how should i set the .listindex? should i just set it to zero?

  16. #16
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: changing combo1.text on runtime

    mine is set to 0- dropdownlist (default) and i just did this
    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Combo1.Text = "lol"
    4.  
    5. End Sub
    I didnt change any property, just the defaults for combo, and it worked fine
    Chris

  17. #17
    Frenzied Member litlewiki's Avatar
    Join Date
    Dec 2005
    Location
    Zeta Reticuli Distro:Ubuntu Fiesty
    Posts
    1,162

    Re: changing combo1.text on runtime

    combo1.listindex = 1
    shows the first value ,atleast for me
    __________________
    ________________0îîî___
    ___îîî0________(___)____
    __(___)_________) _/_____
    ___\_ (_________(_/______
    ____\_)_________________

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