By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Access VBA - CurrentDb.Recordsets is empty

P: 69
As my Access 2002 form opens, I want to find the names of the tables in the current Access database and populate a combobox with them. Problem is, the CurrentDb.Recordsets object is empty even though I have two tables in the database. I'm using the code below, but the combobox remains empty. That's because CurrentDB.Recordsets is empty. Is this a bug with CurrentDb or have I done something dumb?

Expand|Select|Wrap|Line Numbers
  1. Dim TBL As DAO.Recordset
  2.  
  3. For Each TBL In CurrentDb.Recordsets
  4.     Combobox.RowSource = Combobox.RowSource & TBL.Name & ";"
  5. Next TBL
  6.  
Mar 21 '07 #1
Share this Question
Share on Google+
4 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Just set the combobox Row Source to this query ...
Expand|Select|Wrap|Line Numbers
  1. SELECT MsysObjects.Name
  2. FROM MsysObjects
  3. WHERE (((MsysObjects.Name) Not Like '~*' And (MsysObjects.Name) Not Like 'MSys*') AND ((MsysObjects.Type)=1))
  4. ORDER BY MsysObjects.Name;
  5.  
Mary
Mar 21 '07 #2

ADezii
Expert 5K+
P: 8,638
As my Access 2002 form opens, I want to find the names of the tables in the current Access database and populate a combobox with them. Problem is, the CurrentDb.Recordsets object is empty even though I have two tables in the database. I'm using the code below, but the combobox remains empty. That's because CurrentDB.Recordsets is empty. Is this a bug with CurrentDb or have I done something dumb?

Expand|Select|Wrap|Line Numbers
  1. Dim TBL As DAO.Recordset
  2.  
  3. For Each TBL In CurrentDb.Recordsets
  4.     Combobox.RowSource = Combobox.RowSource & TBL.Name & ";"
  5. Next TBL
  6.  
Expand|Select|Wrap|Line Numbers
  1. Dim MyTable As TableDef
  2.  
  3. For Each MyTable In CurrentDb.TableDefs
  4.   'No reason to see the System Tables
  5.   If Left$(MyTable.Name, 4) <> "MSys" Then
  6.      MsgBox MyTable.Name
  7.   End If
  8. Next
Mar 21 '07 #3

P: 69
Thanks!!!!!

Expand|Select|Wrap|Line Numbers
  1. Dim MyTable As TableDef
  2.  
  3. For Each MyTable In CurrentDb.TableDefs
  4.   'No reason to see the System Tables
  5.   If Left$(MyTable.Name, 4) <> "MSys" Then
  6.      MsgBox MyTable.Name
  7.   End If
  8. Next
Mar 22 '07 #4

ADezii
Expert 5K+
P: 8,638
Thanks!!!!!
No problemo.
Mar 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.