I have created a control array of labels having same label name. Backend database as access. I have specified the locations in the tables. I need a code for clicking a label. It should map to database and the path mentioned should be opened.
Common array part is
- Private Sub lblLocation_Click(Index As Integer)
-
Dim Result As Long
-
Set db = New Connection
-
Set rs = New Recordset
-
query = "SELECT [location],[sno],[Initial],[Updated] FROM [tblDetails] WHERE [module_name] = '" & _
-
cmboModule.Text & "'"
-
-
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DocTraK\DocTrak.mdb;"
-
rs.Open query, db, adOpenStatic, adLockOptimistic
-
For i = 0 To 4
-
lblLocation(i).Caption = ""
-
Next i
-
-
If Not rs.BOF Then
-
rs.MoveFirst
-
End If
-
-
rows = rs.RecordCount
-
For i = 1 To rows
-
If i > 5 Then
-
GoTo Over
-
End If
-
lblLocation(i - 1).Caption = rs.Fields(0)
-
rs.MoveNext
-
Next i
-
Over:
-
db.Close
-
Result = MsgBox("Do You want to open the following document?", _
-
vbYesNo + vbQuestion)
-
If Result = vbYes Then
-
Selection.Hyperlinks(i).rs.Fields (0)
-
Else
-
MsgBox "Please check the data is correct?", vbInformation
-
End If
-
End Sub
I need a proper code to get open all the documents placed in the record set