What I need to do is populate a combo box at runtime according to specific inputs from other forms.The code listed below is a seperate trial and works OK. I would like to know if I am overdoing the code thing for what I am achieving.
Private Sub Form_Load() Set myconn = New ADODB.Connection myconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\Gareth Powell\Desktop\db2.mdb" myconn.Open Set mycomm = New ADODB.Command Set mycomm.ActiveConnection = myconn mycomm.CommandType = adCmdText mycomm.CommandText = "SELECT res FROM table1" Set myRS = mycomm.Execute Do Until myRS.EOF = True Combo1.AddItem myRS!res myRS.MoveNext Loop Set myRS = Nothing Set mycomm = Nothing Set myconn = Nothing End Sub
Secondly, in the SQL statement and AddItem statements where I have used column name 'res' , ideally I will want to use column names which are numbers eg 7609.
However, when I use a numerical column name it results in a
compile error expected:end of statement error
Any suggestions gratefully received, as always!!:-/