不要引用控件的文本属性。它仅在控件具有焦点时可用。如果必须使用属性,请使用值。
Me.Image5.Picture = "C:\Users\Milad\Desktop\club imgs\" & Me.Club_Name & ".png"
您还可以通过使用“真实”名称来检查它是否正常工作:
Me.Image5.Picture = "C:\Users\Milad\Desktop\club imgs\FCB.png"
重新评论
sPath = CurrentProject.Path & "\"
sBlank = "Blank.png" ''Your own default empty picture
If IsNull(Me.Club_Name) Then
sFile = sBlank
Else
''Does the file exist? Note: Use FilesystemObject
''instead if you are working network paths.
sFile = Dir(sPath & Me.Club_Name & ".png")
''Empty string ("")
If sFile = vbNullString Then
sFile = sBlank
End If
End If
Me.Image5.Picture = sPath & sFile