Connecting Tech Pros Worldwide Forums | Help | Site Map

How to read values from a combo box using VBA

Shiva
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi,

I'm trying to read and count the values of a combo box (called filetype) on
a subform. The possible values of the combo box depend on a SQL-query
assigned to the rowsource property of the combo box.

Here's a piece of the code:

Dim rs As ADODB.Recordset

Set rs = Form_Subform_films.filetype.Recordset.Clone

If rs.RecordCount = 1 Then
GetSingleAvailableFiletype_id = Str(rs![Id])
End If

rs.Close
Set rs = Nothing

The second command (Set rs = Form..) generates a type mismatch error. What's
wrong?

I'm using Access 2002 so ADO Recordsets should work

Thanks in advance!



Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 13 '05

re: How to read values from a combo box using VBA


On Wed, 2 Mar 2005 23:07:45 +0100, "Shiva" <shiva087@hotmail.com>
wrote:

The recordsetclone is a DAO object.
Set a reference to DAO 3.6 (code window/ Tools/ References), and
change the Dim statement to:
Dim rs as DAO.Recordset

-Tom.

[color=blue]
>Hi,
>
>I'm trying to read and count the values of a combo box (called filetype) on
>a subform. The possible values of the combo box depend on a SQL-query
>assigned to the rowsource property of the combo box.
>
>Here's a piece of the code:
>
>Dim rs As ADODB.Recordset
>
>Set rs = Form_Subform_films.filetype.Recordset.Clone
>
>If rs.RecordCount = 1 Then
>GetSingleAvailableFiletype_id = Str(rs![Id])
>End If
>
>rs.Close
>Set rs = Nothing
>
>The second command (Set rs = Form..) generates a type mismatch error. What's
>wrong?
>
>I'm using Access 2002 so ADO Recordsets should work
>
>Thanks in advance!
>[/color]

Closed Thread