473,396 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Run Time error in VBA code when trying to access rows from a table

6
I am trying to access certain rows in a table in a combo box. 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.OpenRecordset(sql)





If Me.Combo43 = rs.Fields(0) Then

DoCmd.RunMacro ("macDeleteROLL0300Data")
'cmdDelete.Enabled = False

Dim rolldt As String
Dim rsroll As Recordset

Strsql = "SELECT Max(tblROLL0300.DATE) AS MaxOfDATE " & _
"FROM tblROLL0300;"
Set rsroll = CurrentDb.OpenRecordset(Strsql)
rolldt = rsroll!MaxOfDATE

txtRoll.SetFocus
txtRoll.Text = rolldt

rsroll.Close

ElseIf Me.Combo43 = rs.Fields(1) Then
DoCmd.RunMacro ("macDeleteCurrentCollAcctArch")

ElseIf Me.Combo43 = rs.Fields(3) Then
DoCmd.RunMacro ("macCollectedAccountARCHIVE")
End If
Jul 26 '07 #1
2 1375
MMcCarthy
14,534 Expert Mod 8TB
Not sure whats going on but try changing

If Me.Combo43 = rs.Fields(0) Then

to

If Me.Combo43 = rs!List Then

If that doesn't work can you tell us which line the code stops at?
Aug 6 '07 #2
MMcCarthy
14,534 Expert Mod 8TB
Sorry I just had another look, the following code won't work as you have only returned one field (list) in your recordset
Expand|Select|Wrap|Line Numbers
  1. ElseIf Me.Combo43 = rs.Fields(1) Then
  2.     DoCmd.RunMacro ("macDeleteCurrentCollAcctArch")
  3.  
  4. ElseIf Me.Combo43 = rs.Fields(3) Then
  5.     DoCmd.RunMacro ("macCollectedAccountARCHIVE")
  6. End If
  7.  
What exactly is it you are trying to do?
Aug 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
3
by: Reney | last post by:
I am using Access Database in my program. The column in the table that I am going to use has date/time value with Medium Time selected. (HH:mm). The program is recording a clock in time to this...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.