am trying to access certain rows in a table through a combo box.Basically what I am trying to do is when I select "Delete Data" from the combo box and click the go button it will run a macro. I get this error (Run-time error '3265' Item not found in this collection) Here is the code. I am new to VBA so please excuse me. Here is the code:
Private Sub GO_Click()
Set rec = New ADODB.Recordset
Dim rs As Recordset
Dim sql As String
Dim Combo43 As ComboBox
sql = "SELECT tblListBox.List FROM tblListBox;"
Set rs = CurrentDb.OpenR ecordset(sql)
If Me.Combo43 = rs.Fields(0) Then
DoCmd.RunMacro ("macDeleteROLL 0300Data")
'cmdDelete.Enab led = False
Dim rolldt As String
Dim rsroll As Recordset
Strsql = "SELECT Max(tblROLL0300 .DATE) AS MaxOfDATE " & _
"FROM tblROLL0300;"
Set rsroll = CurrentDb.OpenR ecordset(Strsql )
rolldt = rsroll!MaxOfDAT E
txtRoll.SetFocu s
txtRoll.Text = rolldt
rsroll.Close
ElseIf Me.Combo43 = rs.Fields(1) Then
DoCmd.RunMacro ("macDeleteCurr entCollAcctArch ")
ElseIf Me.Combo43 = rs.Fields(3) Then
DoCmd.RunMacro ("macCollectedA ccountARCHIVE")
End If
--------------------------------------------------------------------------------
Private Sub GO_Click()
Set rec = New ADODB.Recordset
Dim rs As Recordset
Dim sql As String
Dim Combo43 As ComboBox
sql = "SELECT tblListBox.List FROM tblListBox;"
Set rs = CurrentDb.OpenR ecordset(sql)
If Me.Combo43 = rs.Fields(0) Then
DoCmd.RunMacro ("macDeleteROLL 0300Data")
'cmdDelete.Enab led = False
Dim rolldt As String
Dim rsroll As Recordset
Strsql = "SELECT Max(tblROLL0300 .DATE) AS MaxOfDATE " & _
"FROM tblROLL0300;"
Set rsroll = CurrentDb.OpenR ecordset(Strsql )
rolldt = rsroll!MaxOfDAT E
txtRoll.SetFocu s
txtRoll.Text = rolldt
rsroll.Close
ElseIf Me.Combo43 = rs.Fields(1) Then
DoCmd.RunMacro ("macDeleteCurr entCollAcctArch ")
ElseIf Me.Combo43 = rs.Fields(3) Then
DoCmd.RunMacro ("macCollectedA ccountARCHIVE")
End If
--------------------------------------------------------------------------------
Comment