Ok I have a form with 4 comboboxes and 1 listbox, this form searches the db for the corresponding record to the search, the user then selects an item in the listbox, clicks a command button to open an new form with various textboxes corresponding to the db fields. On form load it is loading the record of only the first item in the list box, not the selected item. I have included the search form code and the view form code respectively:
This code will load fill the listbox properly
Function search_audits()
Dim statement As String
Dim search As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C:\...\mydb.mdb"
cn.Open
Set rs = New ADODB.Recordset
rs.Open "tbl_001_RawData", cn, adOpenKeyset, adLockPessimistic, adCmdTable
search = "[Manager] = '" & frmSearch.cmbTLInfo.Text & "' AND [Queue] = '" & frmSearch.cmbQueue.Text & "' AND [Location] = '" & frmSearch.cmbLocation.Text & "' AND [WE] = '" & frmSearch.cmbWE.Text & "'"
statement = "SELECT FullName, Call_ID, Eval_Date FROM tbl_001_RawData Where " & search
Set rs = cn.Execute(statement, , adCmdText)
frmSearch.lstAgent.Clear
Do While Not rs.EOF
frmSearch.lstAgent.AddItem rs!Eval_Date & " " & rs!FullName & " " & rs!SVCTG
rs.MoveNext
Loop
rs.Close
cn.Close
End Function
:confused: It is this code that I have having the problem with
Private Sub Form_Load()
On Error Resume Next
Set dbMyDB = OpenDatabase("C:\...\mydb.mdb")
Set rsMyRS = dbMyDB.OpenRecordset("tbl_001_RawData", dbOpenDynaset)
rsMyRS.FindNext "AuditNum=" & Str(frmSearch.lstAgent.ItemData(frmSearch.lstAgent.ListIndex))
txtInfo(0).Text = rsMyRS!FullName
txtInfo(1).Text = rsMyRS!Manager
txtInfo(2).Text = rsMyRS!QA_Rater
txtInfo(3).Text = rsMyRS!Call_Date
txtInfo(4).Text = rsMyRS!Eval_Date
txtInfo(5).Text = rsMyRS!Call_ID
txtInfo(6).Text = rsMyRS!Item_ID
txtInfo(7).Text = rsMyRS!Call_Type
txtInfo(8).Text = rsMyRS!Problem
rsMyRS.MoveNext
rsMyRS.Close
dbMyDB.Close
End Sub