A
Alan
This is hopefully a simple question.
I have a Sub Routine that I was given a bit of help with previously that
updates a number of captions on any form, details of which are stored in
tblControlSQL
Public Sub UpdateFormInfo(strDataSet As String)
Dim rstData As Recordset
Dim CtrlSource As Control
strSQL = "SELECT * FROM tblControlSQL WHERE (((tblControlSQL.DATASET)='" &
strDataSet & "') AND ((tblControlSQL.Type)='Button'))"
Set rstData = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
While rstData.EOF = False
With rstData
Set CtrlSource = Forms!UpdateData.Controls(.Fields("Name"))
CtrlSource.Caption = .Fields("CountRowsValue")
If CtrlSource.Caption = 0 Then
CtrlSource.ForeColor = 32768
ElseIf CtrlSource.Caption = "N/A" Then
ctl.ForeColor = vbBlack
Else: CtrlSource.ForeColor = vbRed
End If
.MoveNext
End With
Wend
End Sub
I can now see a use for reusing this code and would like it to work on other
Forms other than 'Forms!UpdateData'... can anyone point me in the right
direction of having a Forms variable ???
I have tried changing the sub to UpdateFormInfo(strDataSet As String,
FormName as Form) however continually get errors.
Any help would be gratefully appreciated
Regards
I have a Sub Routine that I was given a bit of help with previously that
updates a number of captions on any form, details of which are stored in
tblControlSQL
Public Sub UpdateFormInfo(strDataSet As String)
Dim rstData As Recordset
Dim CtrlSource As Control
strSQL = "SELECT * FROM tblControlSQL WHERE (((tblControlSQL.DATASET)='" &
strDataSet & "') AND ((tblControlSQL.Type)='Button'))"
Set rstData = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
While rstData.EOF = False
With rstData
Set CtrlSource = Forms!UpdateData.Controls(.Fields("Name"))
CtrlSource.Caption = .Fields("CountRowsValue")
If CtrlSource.Caption = 0 Then
CtrlSource.ForeColor = 32768
ElseIf CtrlSource.Caption = "N/A" Then
ctl.ForeColor = vbBlack
Else: CtrlSource.ForeColor = vbRed
End If
.MoveNext
End With
Wend
End Sub
I can now see a use for reusing this code and would like it to work on other
Forms other than 'Forms!UpdateData'... can anyone point me in the right
direction of having a Forms variable ???
I have tried changing the sub to UpdateFormInfo(strDataSet As String,
FormName as Form) however continually get errors.
Any help would be gratefully appreciated
Regards