Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing an image from a Crystal DSR from within VB

Status
Not open for further replies.

bbrendan

IS-IT--Management
Dec 13, 2001
109
GB
Hi there,

I have a table with Order Detail Lines, which I would like to add a picture to using a DSR from within crystal reports. There can be 1 or more detail lines, so I would like to display 1 or more images for a record.

I can successfully get the code to access the first record and show the image, but when I want to show the second record, it shows the original image!!!

Ive debugged it and watch that the detail section loops through the recordset, but it just re-opens the recordset again and starts from the beginning.

how can I get the recordset to move to the next record??


--------------
Private Sub DetailSection1_Format(ByVal pFormattingInfo As Object)

Dim myBmp As StdPicture
Dim crORS As ADODB.Recordset
Dim objConn As ADODB.Connection
Dim strConnect As String
Dim strSQL As String
Dim Order_ID As Double

strConnect = INI_getString("String", "ConnectString1", App.Path & "\dataconn.ini")

Order_ID = frmMain.TDBGridDebtB.Columns(0).Value

strSQL = "Select o.* from Order_Item o " & _
"where o.order_id =" & Order_ID

Set objConn = New ADODB.Connection
Set crORS = New ADODB.Recordset

crORS.Open strSQL, strConnect, adOpenStatic, adLockReadOnly

picFile = App.Path & "\image\"

crORS.MoveFirst

picFile = picFile & crORS.Fields("Batch_ID").Value & "_" & crORS.Fields("Image_ID").Value & ".jpg"

Set myBmp = LoadPicture(picFile)

Set Picture2.FormattedPicture = myBmp

End Sub

---------------

any help would be very appreciated

thanks
 
The problem is that you're going through the exact same recordset every time the Detail's FormatSection event is called, which always results in the last 'crORS.Fields("Image_ID").Value' in the recordset.

Is the field containing the image name in the Details section of the report? If so, that's where you need get the value from. If not, do whatever you can to get it returned as part of the report's recordset. Since you're using .dsr's, you would just need to identify the name the field was given in the IDE, then update your code accordingly, e.g., if 'Field4' is the field:
[tt]
picFile = App.Path & "\image\"
picFile = picFile & Field4.Value & ".jpg"
Set Picture2.FormattedPicture = LoadPicture(picFile)
[/tt]
-dave
 
hi vidru,

Thanks, you were spot on!. I was using the recordset and not the Crystal report fields!

thanks for your help!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top