A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Lit box problems...



 
 
Thread Tools Display Modes
  #1  
Old August 19th, 2004, 11:53 AM
Mo
external usenet poster
 
Posts: n/a
Default 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  
Old August 19th, 2004, 01:25 PM
Dan Artuso
external usenet poster
 
Posts: n/a
Default

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  
Old August 19th, 2004, 01:41 PM
Mo
external usenet poster
 
Posts: n/a
Default

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  
Old August 19th, 2004, 02:18 PM
Mo
external usenet poster
 
Posts: n/a
Default

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  
Old August 19th, 2004, 03:02 PM
Dan Artuso
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 07:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.