If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Lit box problems...
I've got an unbound listbox on a form, and for the item that's currently
selected from the listbox, I'm trying to find out how many exist in the underlying table (i.e. the same as rst.recordcount) The field I'm using is called CN and is an integer I'm having problems with the following code and getting a 'Type mismatch' error message. Anyone know what I'm doing wrong? Thanks for any help. -------------code snippet-------------- For Each varItem In Me.list_main.ItemsSelected strWhere = "CN = " & Me.list_main.ItemData(varItem) & "" Next varItem strSQL = "SELECT CN FROM tblRegistration " strSQL = strSQL & "WHERE " & strWhere Set rst = db.OpenRecordset(strSQL, dbOpenDynaset) ------------------------------ |
#2
|
|||
|
|||
Hi,
If it's an integer, use this: strWhere = "CN = " & Me.list_main.ItemData(varItem) HTH Dan Artuso, MVP "Mo" wrote in message ... I've got an unbound listbox on a form, and for the item that's currently selected from the listbox, I'm trying to find out how many exist in the underlying table (i.e. the same as rst.recordcount) The field I'm using is called CN and is an integer I'm having problems with the following code and getting a 'Type mismatch' error message. Anyone know what I'm doing wrong? Thanks for any help. -------------code snippet-------------- For Each varItem In Me.list_main.ItemsSelected strWhere = "CN = " & Me.list_main.ItemData(varItem) & "" Next varItem strSQL = "SELECT CN FROM tblRegistration " strSQL = strSQL & "WHERE " & strWhere Set rst = db.OpenRecordset(strSQL, dbOpenDynaset) ------------------------------ |
#3
|
|||
|
|||
Hello Dan,
I've tried that particular thing before and I get the same error message 'Type mismatch'. Any other ideas? "Dan Artuso" wrote in message ... Hi, If it's an integer, use this: strWhere = "CN = " & Me.list_main.ItemData(varItem) HTH Dan Artuso, MVP |
#4
|
|||
|
|||
OK Dan, sorted. Changed this:
Dim db As Database Dim rst As Recordset to this: Dim db As DAO.Database Dim rst As DAO.Recordset and it now works. Wierd!! "Dan Artuso" wrote in message ... Hi, If it's an integer, use this: strWhere = "CN = " & Me.list_main.ItemData(varItem) HTH Dan Artuso, MVP |
#5
|
|||
|
|||
Hi,
It's not wierd at all. If you have a reference to both ADO and DAO, they both have recordset objects. If you don't use the DAO qualifier (or any qualifier) Access will pick the library that is referenced first, in this case ADO. Hence the type mismatch. When posting, you should always give the line that is causing the error! Dan Artuso, MVP "Mo" wrote in message ... OK Dan, sorted. Changed this: Dim db As Database Dim rst As Recordset to this: Dim db As DAO.Database Dim rst As DAO.Recordset and it now works. Wierd!! "Dan Artuso" wrote in message ... Hi, If it's an integer, use this: strWhere = "CN = " & Me.list_main.ItemData(varItem) HTH Dan Artuso, MVP |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Video Problems | Robert | Powerpoint | 4 | August 19th, 2004 04:42 PM |
OE 6 Problems | Rick A. | Outlook Express | 2 | July 16th, 2004 02:21 PM |
Problems with posting email/news messages via OE6 and working with Web-based email | Alex Vinokur | Outlook Express | 2 | June 18th, 2004 01:56 PM |
Publisher 2003 web page problems | LoBo Designs | Publisher | 1 | June 17th, 2004 05:01 AM |
What problems can I expect with 1000 hyperlinks? | Peter Noneley | Links and Linking | 0 | November 25th, 2003 11:04 AM |