Apr 16th, 2006, 12:45 AM
#1
Thread Starter
Hyperactive Member
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:
Text1.Text = fsave
Combo1.Text = Text1.Text 'PROBLEM HERE, combo won't show the text
Attached Files
Last edited by Whatupdoc; Apr 16th, 2006 at 02:40 AM .
Apr 16th, 2006, 01:41 AM
#2
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"
Apr 16th, 2006, 01:44 AM
#3
Thread Starter
Hyperactive Member
Re: changing combo1.text on runtime
hmm that doevent didn't work either
Apr 16th, 2006, 01:47 AM
#4
Re: changing combo1.text on runtime
Stupid to ask but how about
Combo1.Text = fsave
Apr 16th, 2006, 01:53 AM
#5
Thread Starter
Hyperactive Member
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...
Apr 16th, 2006, 01:56 AM
#6
Re: changing combo1.text on runtime
Do you get any errors or anything or does it just not change?
Apr 16th, 2006, 01:59 AM
#7
Thread Starter
Hyperactive Member
Re: changing combo1.text on runtime
no errors, the text on the combo just clears.
Apr 16th, 2006, 02:12 AM
#8
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
Apr 16th, 2006, 02:17 AM
#9
Re: changing combo1.text on runtime
Would this work?
VB Code:
Dim ChgCmb As Boolean
Private Sub Combo1_Click()
If ChgCmb Then Exit Sub
Dim fsave As String
CommonDialog1.Filter = ".txt" 'this sets what filestypes can be saved
CommonDialog1.DialogTitle = "Please select the list you want to use"
CommonDialog1.InitDir = App.Path
CommonDialog1.ShowOpen 'shows "Open Dialog Box"
fsave = CommonDialog1.FileName 'the file the user selected is "FSave"
If Len(fsave) < 2 Then
MsgBox "Please Select a File!", vbCritical
Exit Sub
End If
ChgCmb = True
Text1.Text = fsave
Combo1.AddItem Text1.Text, 0
Combo1.ListIndex = Combo1.NewIndex
ChgCmb = False
End Sub
Apr 16th, 2006, 02:41 AM
#10
Thread Starter
Hyperactive Member
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
Apr 16th, 2006, 02:48 AM
#11
Re: changing combo1.text on runtime
Sorry i wasn't much help
Apr 16th, 2006, 06:08 AM
#12
Re: changing combo1.text on runtime
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.
Apr 16th, 2006, 06:15 AM
#13
Re: changing combo1.text on runtime
did u try the .listindex property method ??
__________________
________________0îîî___
___îîî0________(___)____
__(___)_________) _/_____
___\_ (_________(_/______
____\_)_________________
Apr 16th, 2006, 06:23 AM
#14
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
Apr 16th, 2006, 11:40 AM
#15
Thread Starter
Hyperactive Member
Re: changing combo1.text on runtime
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?
Apr 16th, 2006, 12:19 PM
#16
Re: changing combo1.text on runtime
mine is set to 0- dropdownlist (default) and i just did this
VB Code:
Private Sub Form_Load()
Combo1.Text = "lol"
End Sub
I didnt change any property, just the defaults for combo, and it worked fine
Apr 16th, 2006, 02:01 PM
#17
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
Forum Rules
Click Here to Expand Forum to Full Width