Calling Control Info from Table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Not sure I have the title right here, but here goes
Thanks to an earlier post I now have my Form with many buttons beautifully
coloured etc. However as I update the information the data on screen becomes
dated ... I have toyed with the idea of storing information about Control
Objects in a table alongside the SQL that provides the value and have written
a small if loop to attempt to marshal this function however am clearly going
somewhere wrong

Dim rstData As Recordset
Dim CtrlSource As Control
Dim Executable As String

strSQL = "SELECT * FROM tblControlSQL WHERE
(((tblControlSQL.DATASET)='Employee'))"
Set rstData = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)

While rstData.EOF = False
With rstData
Set CtrlSource = .Fields("Name")
Executable = .Fields("ExecutableSQL")
CtrlSource = CountRows(Executable)
.MoveNext

End With
Wend

I had hoped this would update all buttons and text boxed called from the
SELECT statement viz Forms!btnParttime.Caption = *the result of the SQL
associated in the table
Maybe Im way of the mark here .. Can anyone tell me if this is possible or
where i should look for an alternative

Many Thanks
 
One thing that pops out is your CtrSource variable. You have it dimmed as a
control, but your trying to set it with a string. Try:

Set CtrlSource = Me.Controls(.Fields("Name"))
Then, I'm not sure what your CountRows function does, but I think you want
to populate the control's controlSource from the table. If so, this might
work:
CtrlSource.COntrolSource = .Fields("ExecutableSQL")

Barry
 
Back
Top