|
-
Feb 24th, 2007, 08:36 PM
#1
Thread Starter
Junior Member
[RESOLVED] Display Access table components in a combobox
I have a combobox that i want to display items from a single row table from MSAccess.
How can i do this?
Thanks in advance
-
Feb 25th, 2007, 12:06 AM
#2
Re: Display Access table components in a combobox
VB Code:
Set rs = New ADODB.Recordset
Set conn = New ADODB.Connection
conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "\yourdb.mdb;Uid=;Pwd=;"
conn.CursorLocation = adUseClient
conn.Open
rs.Open "SELECT * FROM `tbl_tablename`", conn
Do While Not rs.EOF
cmbComboBox.AddItem Trim(rs!fieldname & "")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
My usual boring signature: Something
-
Feb 25th, 2007, 11:27 AM
#3
Thread Starter
Junior Member
Re: Display Access table components in a combobox
Thanks for the reply DClamp,
I´m getting an error:
Runtime Error '-2147467259(80004005)
[Microsoft][Microsoft access ODBC Controller] It´s not a valid file name.
-
Feb 25th, 2007, 01:09 PM
#4
Re: Display Access table components in a combobox
did you change the control names and the database name to match your program?
My usual boring signature: Something
-
Feb 25th, 2007, 01:15 PM
#5
Thread Starter
Junior Member
Re: Display Access table components in a combobox
yes dclamp, it looks like this now:
VB Code:
Set rs = New ADODB.Recordset
Set conn = New ADODB.Connection
conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & App.Path & "C:\Documents and Settings\Leo & Glory\Mis documentos\ppe.mdb;Uid=;Pwd=;"
conn.CursorLocation = adUseClient
conn.Open
rs.Open "SELECT * FROM PPE", conn
Do While Not rs.EOF
cmbCombo6.AddItem Trim(rs!fieldname & "")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
-
Feb 25th, 2007, 06:38 PM
#6
Re: Display Access table components in a combobox
dclamp used App.Path to automatically detect the program path (assuming that the mdb file is in the same folder as the program), so you need to remove " & App.Path & "
-
Feb 25th, 2007, 07:35 PM
#7
Thread Starter
Junior Member
Re: Display Access table components in a combobox
-
Feb 25th, 2007, 07:41 PM
#8
Re: [RESOLVED] Display Access table components in a combobox
dont forget to mark this thread as resolved, and give rep
My usual boring signature: Something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|