Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc,microsoft.public.excel.newusers,microsoft.public.excel.programming
|
|||
|
|||
Combobox or Listbox
Can a combobox and a listbox on a userform get their list items from a query or
table in an Access database? How? Thanks, Kathy |
#2
Posted to microsoft.public.excel.misc,microsoft.public.excel.newusers,microsoft.public.excel.programming
|
|||
|
|||
Combobox or Listbox
Kathy
please do not cross-post. The same people tend to look at all the groups so you won't get more answers, just more irritated volunteers Regards Trevor "Kathy" wrote in message ink.net... Can a combobox and a listbox on a userform get their list items from a query or table in an Access database? How? Thanks, Kathy |
#3
Posted to microsoft.public.excel.misc,microsoft.public.excel.newusers,microsoft.public.excel.programming
|
|||
|
|||
Combobox or Listbox
This code selects two columns, a key and a column respectively. The
key is shown in the combo's first (hidden) column, the data in its second (visible) column. I've used appropriate recordset settings in case you want to be able to update the source. '----------------------- Option Explicit Private Sub UserForm_Initialize() Dim m_oConn As Object Dim m_oRS As Object Const strCONNECTION As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" Const strPATH As String = "C:\Tempo\New_Jet_DB.mdb" Const strSQL As String = "SELECT RefID, Surname FROM PersonalDetails" Dim vntArray As Variant Set m_oConn = CreateObject("ADODB.Connection") m_oConn.Open strCONNECTION & strPATH Set m_oRS = CreateObject("ADODB.Recordset") With m_oRS .CursorLocation = 3 ' adUseClient .CursorType = 3 ' adOpenStatic .LockType = 4 ' adLockBatchOptimistic .ActiveConnection = m_oConn .Command = strSQL .Open End With With ComboBox1 .ColumnCount = 2 .BoundColumn = 1 .TextColumn = 2 .ColumnWidths = "0;" ' first column invisible vntArray = m_oRS.GetRows .List = Application.Transpose(vntArray) End With End Sub '---------------------- "Trevor Shuttleworth" wrote in message ... Kathy please do not cross-post. The same people tend to look at all the groups so you won't get more answers, just more irritated volunteers Regards Trevor "Kathy" wrote in message ink.net... Can a combobox and a listbox on a userform get their list items from a query or table in an Access database? How? Thanks, Kathy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Combobox/Listbox Difference | Excel Discussion (Misc queries) | |||
Combobox v Listbox | New Users to Excel | |||
Combobox/listbox | Excel Discussion (Misc queries) | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
listbox-combobox category | Excel Programming |