PrimoSteve
Technical User
Hello All,
I have a subform that acts like a grid that displays 24 command button ( 4 Rows and 6 columns)
tblCmds
cmdID Short Text
cmdCaption Short Text
cmdPhotoUrl Short Text
Private Sub Form_Load()
On Error GoTo FormLoadErr:
Dim ctl As Control
Me.cTemp.SetFocus
For Each ctl In Me.Controls
If TypeOf ctl Is CommandButton Then
If ctl.Name Like "cmdOrder*" Then
ctl.Visible = True
ctl.Caption = DLookup("[cmdCaption]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
If ctl.Caption = "Empty" Then ctl.Visible = False
End If
End If
Next ctl
DoCmd.Save
Exit Sub
FormLoadErr:
MsgBox ctl.Name & "-" & err.Description
End Sub
The following code above works fine to display the caption but when I add the following line of code to display the picture.
ctl.Picture = DLookup("[cmdPhotoUrl]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
I get this error
"cmdOrder02-SampleDB can't open tje file
'C:\Users\Admin\Documents\Parts1.png'."
Any assistance would help in writing this code the correct way
For Each ctl In Me.Controls
If TypeOf ctl Is CommandButton Then
If ctl.Name Like "cmdOrder*" Then
ctl.Visible = True
ctl.Caption = DLookup("[cmdCaption]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
ctl.Picture = DLookup("[cmdPhotoUrl]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
If ctl.Caption = "Empty" Then ctl.Visible = False
End If
End If
Next ctl
DoCmd.Save
Regards
Primo
I have a subform that acts like a grid that displays 24 command button ( 4 Rows and 6 columns)
tblCmds
cmdID Short Text
cmdCaption Short Text
cmdPhotoUrl Short Text
Private Sub Form_Load()
On Error GoTo FormLoadErr:
Dim ctl As Control
Me.cTemp.SetFocus
For Each ctl In Me.Controls
If TypeOf ctl Is CommandButton Then
If ctl.Name Like "cmdOrder*" Then
ctl.Visible = True
ctl.Caption = DLookup("[cmdCaption]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
If ctl.Caption = "Empty" Then ctl.Visible = False
End If
End If
Next ctl
DoCmd.Save
Exit Sub
FormLoadErr:
MsgBox ctl.Name & "-" & err.Description
End Sub
The following code above works fine to display the caption but when I add the following line of code to display the picture.
ctl.Picture = DLookup("[cmdPhotoUrl]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
I get this error
"cmdOrder02-SampleDB can't open tje file
'C:\Users\Admin\Documents\Parts1.png'."
Any assistance would help in writing this code the correct way
For Each ctl In Me.Controls
If TypeOf ctl Is CommandButton Then
If ctl.Name Like "cmdOrder*" Then
ctl.Visible = True
ctl.Caption = DLookup("[cmdCaption]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
ctl.Picture = DLookup("[cmdPhotoUrl]", "tblCmds", "[cmdID]='" & ctl.Name & "'")
If ctl.Caption = "Empty" Then ctl.Visible = False
End If
End If
Next ctl
DoCmd.Save
Regards
Primo