Calling Control Info from Table

A

Alan

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
 
B

Barry Gilbert

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top