If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
using Control to populate combobox
Dear,
I have a form where I have to populate different combo boxes at different stages with data from a separate database. I’m trying to write a Function that would easily repeat the task, the main problem is specifying what combo box to use. This is what I think it should look like. Public Sub LoadCB(cbName As Control, SelectionString As String) cbCount = 0 Set rstLoadCB = VMSDatabase.OpenRecordset(SelectionString) With rstLoadCB For each X in rstLoadCB cbName.AddItem (current record) Next End If end With End Sub I’m not having any luck with all my variations of the code, could someone please help me Regards Ingo |
#2
|
|||
|
|||
using Control to populate combobox
If you intend to open a database you need to let Access know where it is,
maybe something like this: Dim db As DAO.Database Dim rs As DAO.Recordset Dim strPath As String, strMsg As String, strTitle As String strPath = "\\ServerName\ShareName\DatabaseName.mdb" Set db = OpenDatabase(strPath) Set rs = db.OpenRecordset("TableName", dbOpenDynaset) AFAIK you can't loop through a recordset as you have shown, but in any case what is X supposed to be? It seems you may be trying to loop through controls, but in that case you won't find them in a recordset. Why not link to the tables you need? It's difficult to sort out what you are trying to do, but some more explanation would help. Ingo Hanke wrote: Dear, I have a form where I have to populate different combo boxes at different stages with data from a separate database. I’m trying to write a Function that would easily repeat the task, the main problem is specifying what combo box to use. This is what I think it should look like. Public Sub LoadCB(cbName As Control, SelectionString As String) cbCount = 0 Set rstLoadCB = VMSDatabase.OpenRecordset(SelectionString) With rstLoadCB For each X in rstLoadCB cbName.AddItem (current record) Next End If end With End Sub I’m not having any luck with all my variations of the code, could someone please help me Regards Ingo -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201003/1 |
Thread Tools | |
Display Modes | |
|
|