(c) 2001 Visual Studio Magazine
Fawcette Technical Publications

Issue
February 2002
Section
Getting Started column
Main file name
vs0202GSt5.rtf

Listing 1
VB6
Use the ADO Data Control to Display Detailed Information
The DataRepeater control is used in the example project to display concise information so that the user can quickly isolate specific records. Read the ADO Data Control's recordset to obtain and display detailed information on the client form.

Sub ShowImageID()

Dim strSQL As String
Dim fImage As frmImage
Dim intCounter As Integer
Dim strMsg As String

If (Adodc1.Recordset.BOF) And _
	(Adodc1.Recordset.EOF) Then _
	Exit Sub

'get the unique ImageID from the
'ADO data control
intCounter = Adodc1.Recordset(0)
If (intCounter < 0) Then
	strMsg = "Could not " & _
		"determine ImageID..."
	MsgBox strMsg, _
		vbExclamation, _
		"Cannot Display Image..."
	Exit Sub
End If

'show only the selected record
strSQL = "SELECT * FROM " & _
	"Images WHERE ImageID = " & _
	intCounter

'create a new instance of the
'detailed client form
Set fImage = New frmImage
With fImage
	'set the RecordSource
	.AdoImages.RecordSource = _
		strSQL
	'refresh the data
	.AdoImages.Refresh
	.Show vbModal
End With
Unload fImage
Set fImage = Nothing

End Sub
