Sub btnFillGridClick(Sender)Dim objRSDim colDim fldDim iDim objConDim strSQL With grdInvoices ' Remove any existing columns If (.Columns.Count > 0) Then For i = 0 To .Columns.Count - 1 .Columns.Item(0).Delete Next End If .ConnectionString = "YourProviderConnectionString" strSQL = "SELECT fields FROM tablename WHERE condition" ' Add new SQL and refresh so grid is bound .SQL.Text = strSQL .Refresh ' Pull the recordset from grid to determine fields in query Set objRS = .Recordset For Each fld In objRS.Fields Set col = .Columns.Add(0) col.FieldName = fld.Name col.Caption = fld.Name ' If field ends in "ID" then assume that field is hidden If Right(LCase(fld.Name), 2) = "id" Then col.Visible = False Next .ReadOnly = True .RowSelect = True .Refresh End WithEnd Sub