Murray Brown
asked on
Access VBA Load Control Info on form or database load
Hi
I have a table called tblAdminForms that holds information on text and images that will be loaded to when the form loads. The following code reads the table when the database loads. Is it possible to assign text to labels and images to image controls for every form and report when the database loads or should I call code on every form load event to load the controls and images
Sub loopTable()
On Error GoTo EH
Dim strSQL As String
Dim rs As DAO.Recordset
Dim oFormOrReport As String
Dim oControlID As String
Dim oControlText As String
Dim oImagePathAndName As String
strSQL = "SELECT * FROM tblAdminForms" 'define the SQL result that you want to loop
Set rs = CurrentDb.OpenRecordset(st rSQL)
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
While (Not rs.EOF)
oFormOrReport = rs.Fields("Form or Report Name") 'define the field you want to return data
oControlID = rs.Fields("Control ID")
oControlText = rs.Fields("Control Text")
oImagePathAndName = rs.Fields("Image Path And Name")
rs.MoveNext
Wend
End If
rs.Close
Set rs = Nothing
Exit Sub
EH:
MsgBox "Error reading tblFormsAdmin table " & Err.Description
End Sub
I have a table called tblAdminForms that holds information on text and images that will be loaded to when the form loads. The following code reads the table when the database loads. Is it possible to assign text to labels and images to image controls for every form and report when the database loads or should I call code on every form load event to load the controls and images
Sub loopTable()
On Error GoTo EH
Dim strSQL As String
Dim rs As DAO.Recordset
Dim oFormOrReport As String
Dim oControlID As String
Dim oControlText As String
Dim oImagePathAndName As String
strSQL = "SELECT * FROM tblAdminForms" 'define the SQL result that you want to loop
Set rs = CurrentDb.OpenRecordset(st
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
While (Not rs.EOF)
oFormOrReport = rs.Fields("Form or Report Name") 'define the field you want to return data
oControlID = rs.Fields("Control ID")
oControlText = rs.Fields("Control Text")
oImagePathAndName = rs.Fields("Image Path And Name")
rs.MoveNext
Wend
End If
rs.Close
Set rs = Nothing
Exit Sub
EH:
MsgBox "Error reading tblFormsAdmin table " & Err.Description
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER