when you click an item of the CombBox - Cmbchapter,
Private Sub Cmbchapter_Click()
'AdRecordset1 - RecordSet object
Dim db1 As Connection
Set db1 = New Connection
db1.CursorLocation = adUseClient
db1.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" & strdatasource
Set AdRecordset1 = New Recordset
AdRecordset1.Open "select Book,BookTitle,Chapter,Verse from BibleTable", db1, adOpenStatic, adLockOptimistic
If Cmbchapter.Enabled = True Then
Setchapter False
adoPrimaryRS.MoveFirst
Cmbchapterrecno.ListIndex = Cmbchapter.ListIndex
'Record number
recordno = Val(Trim(Cmbchapterrecno.Text))
Cmbverse.Clear
Cmbverserecno.Clear
' The Cmbverse stores all verses orders of the chapter corresponding to the item selected.
' The Cmbverserecno stores the orders of the KJV records corresponding to the items of Cmbverse
With AdRecordset1
.MoveFirst
.Move (recordno)
'verse values
Cmbverse.AddItem Trim(.Fields(3).Value)
Cmbverserecno.AddItem Str(Val(.AbsolutePosition) - 1)
Do While Not .EOF
If Trim(.Fields(1).Value) = Trim(Cmbtitle.Text) And _
Trim(.Fields(2).Value) = Trim(Cmbchapter) Then
Cmbverse.AddItem Trim(.Fields(3).Value)
Cmbverserecno.AddItem Str(Val(.AbsolutePosition) - 1)
Else
'1- The record displays into the Record data boxes, includes the following data:
' the order and title of the book display in the Cmbbook and Cmbtitle,
' the item selected,
' the 1st verse order of the chapter
' and the contents of the verse.
'2- In the Cmbchapter, displays the item selected
'3- In the Cmbverse, displays the 1st verse order of the chapter
Cmbverse.ListIndex = 0
Cmbverserecno.ListIndex = Cmbverse.ListIndex
adoPrimaryRS.Move (recordno)
Call LabelAddress
Setchapter True
If Cmbverserecno.Text = 2 Then
CmdFirst.Enabled = False
CmdPrevious.Enabled = False
End If
Exit Sub
End If
.MoveNext
Loop
End With
End If
End Sub
|