'When you click an item of the ComboBox - Cmbbook,
Private Sub Cmbbook_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 Cmbbook.Enabled = True Then
Setbook False
adoPrimaryRS.MoveFirst
Cmbtitlerecno.ListIndex = Cmbbook.ListIndex
Cmbtitle.ListIndex = Cmbbook.ListIndex
'Record number
recordno = Val(Trim(Cmbtitlerecno.Text))
'Cmbchapter, Cmbverse, Cmbchapterrecno, Cmbverserecno controls
Cmbchapter.Clear
Cmbchapterrecno.Clear
Cmbverse.Clear
Cmbverserecno.Clear
'- The Cmbchapter stores all chapters orders of the book corresponding to the item selected
'- The Cmbchapterrecno stores the orders of the KJV records corresponding to the items of Cmbchapter
'- The Cmbverse stores all verses orders of the 1st chapter of the book 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)
vchapter0 = Trim(.Fields(2).Value)
vchapter1 = vchapter0
Cmbchapter.AddItem Trim(.Fields(2).Value)
Cmbchapterrecno.AddItem Str(Val(.AbsolutePosition) - 1)
Cmbverse.AddItem Trim(.Fields(3).Value)
Cmbverserecno.AddItem Str(Val(.AbsolutePosition) - 1)
Do While Not .EOF
If Trim(.Fields(0).Value) = Trim(Cmbbook.Text) Then
If Trim(.Fields(2).Value) <> vchapter1 Then
vchapter1 = Trim(.Fields(2).Value)
Cmbchapter.AddItem Trim(.Fields(2).Value)
Cmbchapterrecno.AddItem Str(Val(.AbsolutePosition) - 1)
Else
If Trim(.Fields(2).Value) = vchapter0 Then
Cmbverse.AddItem Trim(.Fields(3).Value)
Cmbverserecno.AddItem Str(Val(.AbsolutePosition) - 1)
End If
End If
Else
'1- The record displays into the Record data boxes, includes the following data:
' the order and title of the book cooresponding to the item selected,
' the 1st chapter order of the book,
' the 1st verse order of the 1st chapter
' and the contents of the verse.
'2- In the Cmbtitle, displays the title of the book corresponding to the item selected.
'3- In the Cmbbook, displays the item selected.
'4- In the Cmbchapter, displays the 1st chapter order of the book
'5- In the Cmbverse, displays the 1st verse order of the 1st chapter
Cmbchapter.ListIndex = 0
Cmbchapterrecno.ListIndex = Cmbchapter.ListIndex
Cmbverse.ListIndex = 0
Cmbverserecno.ListIndex = Cmbverse.ListIndex
adoPrimaryRS.Move (recordno)
Call LabelAddress
Setbook True
If Cmbtitlerecno.Text = 2 Then
CmdFirst.Enabled = False
CmdPrevious.Enabled = False
End If
Exit Sub
End If
.MoveNext
Loop
End With
End If
End Sub
|