InventoryQueryGuy said:
Hi,
Is it possible to generate a query for column headings in a particular table
so that I can use the results in a combo box?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You'll have to write some VBA code to get the data. You can use ADO
similar to this:
Sub TableColumns(strTable As String)
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open "Data Source=" & CurrentDb.Name
End With
Set rs = cn.OpenSchema(adSchemaColumns)
' find the table we want
With rs
.Find "TABLE_NAME='" & strTable & "'"
Do While .EOF <> True
Debug.Print !TABLE_NAME, !COLUMN_NAME
.MoveNext
.Find "TABLE_NAME='" & strTable & "'", , adSearchForward
Loop
End With
cn.Close
End Sub
You can change the above to just return the COLUMN_NAME & put that in
the ComboBox's drop-down menu - using the .Add method or just make it a
Value List by making the column names a semi-colon delimited string:
col1;col2;col3;col4;col5
And putting the result in the ComboBox's RowSource property (be sure to
change the RowSourceType property to Value List.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBSbhyGYechKqOuFEgEQKlvgCfWcgod58miuF0Cme6U5jIcMhyHFUAnijd
Cx6BSlh37W6p9GWY6n8r9c+3
=tECk
-----END PGP SIGNATURE-----