Hi
I have below code . I want to print image in Crystal Report dynamically. I am using VB6
VB.NET
Private Sub Section5_Format(ByVal pFormattingInfo As Object)
Set Picture1.FormattedPicture = LoadPicture(rs!C_Image)
End SubThanks
Hi
I have below code . I want to print image in Crystal Report dynamically. I am using VB6
Private Sub Section5_Format(ByVal pFormattingInfo As Object)
Set Picture1.FormattedPicture = LoadPicture(rs!C_Image)
End SubThanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Eliana BlakeRank #1,595 · 993 reputationPosted Apr 15, 2025, 7:01 AM EDT
Hi there!
The "Error - Object required" in your VB6 code typically occurs when there is a mismatch in how an object is being referenced or set. In your specific case, the issue lies in the line:
Set Picture1.FormattedPicture = LoadPicture(rs!C_Image)Here, the `Picture1` control is being referenced as an object that needs to be set but without actually being declared or instantiated. To resolve this error, you need to make sure that `Picture1` is correctly defined as an object before using it. In VB6, you can declare and set controls like `Picture1` by adding it to your form design.
Here's a basic example of how you can declare and set a Picture control in VB6:
Private Sub Section5_Format(ByVal pFormattingInfo As Object) Dim Picture1 As Object ' Declare Picture1 as an Object Set Picture1 = Me.Controls("Picture1") ' Assign the Picture control on the form to Picture1 ' Check if Picture1 is not Nothing before setting FormattedPicture If Not Picture1 Is Nothing Then Picture1.FormattedPicture = LoadPicture(rs!C_Image) Else MsgBox "Picture1 control not found on the form!" End If End SubIn this revised code snippet, `Picture1` is declared as an Object and then explicitly assigned the Picture control from the form using `Me.Controls("Picture1")`. This way, you ensure that `Picture1` is properly referenced as an object before attempting to set its properties.
Remember to adjust the control name "Picture1" to match the actual name of the Picture control on your Crystal Report form.
I hope this helps you resolve the "Error - Object required" and successfully print images in your Crystal Report dynamically. If you have any more questions or need further assistance, feel free to ask!