Function LoadBios()
Dim i As Integer
'clear list box if back button used then next button
lstBio1.Clear
Call CreateConnection(objConn)
Set objRs = New ADODB.Recordset
objRs.ActiveConnection = objConn
objRs.CursorLocation = adUseClient
objRs.CursorType = adOpenDynamic
objRs.LockType = adLockOptimistic
objRs.Source = "select * from Bios "
'MsgBox objRs.Source
objRs.Open
For i = 1 To objRs.RecordCount 'adds record then loops thru and gets next record till all records found
'/////// ADDING RECORDS TO LISTBOX
lstBio1.AddItem objRs!b_name '& objRs!b_id
'MsgBox objRs!b_id
lstBio1.ItemData(lstBio1.NewIndex) = objRs!b_id
objRs.MoveNext
Next
objRs.Close
Set objRs = Nothing
Call CloseConnection(objConn)
'frmIntro.fraStep2.Visible = True 'load step2 bios
End Function
'--------------------------------------------------------------------------------
'Here is the code that I use to select from lstBio1 and add to the lstBio2 and the code I use to remove.
'visual basic code:--------------------------------------------------------------------------------
'--------------------------- add bios to list box 2
Private Sub cmdAddBio_Click()
Dim sAdd As String
Found_It = False
If lstBio1.ListIndex <> -1 Then
sAdd = lstBio1
Screen.MousePointer = vbHourglass
For iCount = 0 To lstBio2.ListCount - 1
lstBio2.ListIndex = iCount
If sAdd = lstBio2 Then
Found_It = True
Exit For
End If
Next
If Found_It Then
MsgBox "This item has already been selected"
lstBio2.ListIndex = -1
Else
lstBio2.AddItem lstBio1.Text
iCount = lstBio2.NewIndex
lstBio2.ItemData(lstBio2.NewIndex) = lstBio1.ItemData(lstBio1.ListIndex)
Call CreateConnection(objConn)
sSQL = "INSERT INTO CAMPAIGNDETAILS(cd_id, cd_type, table_id_number) Values ('" & txtGlobalID.Text & "',('BIO')," & lstBio2.ItemData(iCount) & ")"
objConn.Execute (sSQL)
lstBio2.ListIndex = -1
End If
End If
Screen.MousePointer = vbDefault
End Sub
'--------------------------------------------------------------------------------
'And this is the code I use to remove.
'visual basic code:--------------------------------------------------------------------------------
Private Sub cmdRemoveBio_Click()
Screen.MousePointer = vbHourglass
iCount = 0
If lstBio2.ListCount = 0 Then
MsgBox "There are no items to remove"
ElseIf lstBio2.ListIndex = -1 Then
MsgBox "You must first select and item to remove it"
Else
'delete item selected in list box from CampaignDetails table
Call CreateConnection(objConn)
objConn.Execute ("Delete from CampaignDetails where cd_id = '" & txtGlobalID.Text & "' and table_id_number = '" & lstBio2.ItemData(lstBio2.ListIndex) & "'")
Call CloseConnection(objConn)
'remove item from list box
lstBio2.RemoveItem (lstBio2.ListIndex)
End If
Screen.MousePointer = vbDefault
End Sub