hi, there
i hav a combo box on a form, and the form is linked to Access. So, how do i link combo box to Access? Pls help...
thx in advanced.
Printable View
hi, there
i hav a combo box on a form, and the form is linked to Access. So, how do i link combo box to Access? Pls help...
thx in advanced.
If you want to display the contents of one of the fields from yuour DB in a combo use the code below.
VB Code:
Do Until MyRecordset.EOF = True Combo1.Additem MyRecordset!Myitem MyRecordset.Movenext Loop
VB Code:
A very simple way (it works for me) using a Data control with properties set as follows: Recordset Type: Table Database name: your Access file Record source: the Table name Public Sub FillCombo() Dim i As Integer, k As Integer i = Data1.Recordset.RecordCount Data1.Recordset.MoveFirst For k = 0 To i - 1 Combo1.AddItem Data1.Recordset.Fields("FieldName") Data1.Recordset.MoveNext Next End Sub
Hi, the best way i find, is in the form load put this code
obviously source and open your adodb connection
chage obJR to your connection
VB Code:
On Error Resume Next ObJr.MoveFirst Do Until obJr.EOF combo1.AddItem obJR.Fields("Field_Name") ObJr.MoveNext Loop Objr.MoveFirst
hi, there
thx for your helps and the code! i am newbie to VB, so i don't really understand some of the posted VB code.
k0r54 and lintz
hee... if posible, can you pls explain to me the code? thx
krtxmrtz
i am using Data Control too, but where to put the code under Data1_Validate?
actually, i want to use combination of combo box with text box, where GotFocus() and SetFocus() are used.Sth like this. i am not very sure. is it possible? pls show me...
thx in advanced!
My code above just fills a combo with all the records from a specific field.Quote:
krtxmrtz
i am using Data Control too, but where to put the code under Data1_Validate?[/B]
What kind of validation do you mean?
Could you explain better how you want to use this combination of combo + textbox?Quote:
actually, i want to use combination of combo box with text box, where GotFocus() and SetFocus() are used.Sth like this. i am not very sure. is it possible? pls show me...
thx in advanced!
My code fills a combo box from a specified field within your database.