Solved: Variable in a combo box
I want to set up a combo box (Combo11) with a variable Row/whatever source. I have tried (all last three days) using an SQL that looks just like the one that is obtained when the Row source is obtained by the "WIZARD". No luck, So then I try (in underlying VBA) Combox11.RowSource= (My variable), get a NULL, repeat the rowsource and then it works...but only sometimes!
Help??
RePhrase My Combo Box Question
When in Design view, the properties of a combo box include a 'Row Source". If you put a valid SQL statement in this position the combo box works fine, BUT if you put in the name of a variable (An SQL generated someplace else) which is the same valid sql, the combo box either doesn't work, or ACCESS returns with a message saying Such and Such is not found! So how do I put a variable in the combo box's row source?
To:VBX Tutor...Combo Solved!
The programming suggested, using Form_Load, only woked with ONE MySql, but after seeveral days of rest, I found that Defining the MySql in the on Enter event for the combobox worked...IF MySql was a Global variable. Code for two choices follows:
[VBA]Option Compare Database
Dim Mysql As String 'Having been burned with "Global" values, Ikeep
them to a minimum
Private Sub Combo1_Click()
Text13.Value = Combo1 'Signals to developer that he/she has
'something to go on!
End Sub
Private Sub Combo1_Enter()
Combo1.RowSource = Mysql
End Sub
Private Sub Form_Load()
Forms!Form1.Combo1.RowSourceType = "Table/Query"
End Sub
Private Sub Option6_MouseDown(Button As Integer, Shift As Integer,
XAs Single, Y As Single)
Dim MyComments As String
Dim MyTable As String
Forms!Form1.Combo1 = "" 'Clears out contents from last choice.
MyTable = " Table1 "
MyComments = " Comments "
Mysql = "Select " & MyComments & "FROM " & MyTable & ";"
End Sub
Private Sub Option8_GotFocus()
Dim MyComments As String
Dim MyTable As String
Forms!Form1.Combo1 = ""
MyTable = " Table2 "
MyComments = " Comments "
Mysql = "Select " & MyComments & "FROM " & MyTable & ";"
End Sub [/VBA]
Now A simpler priblem: How to "Click' in the Combo after clicking on an option?