DataType Mismatch (1 Viewer)

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
Having a an issue and not sure how this is happenning because I have used this code in a lot of forms.
Code:
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[OwnerID] = '" & Me![lstUsers] & "'"
Me.Bookmark = rs.Bookmark [COLOR="SeaGreen"]<---- error is here for the datatype mismatch or No record found[/COLOR]

OwnerID is a string.

I have tried

Code:
rs.FindFirst "[OwnerID] = '" & Me.lstUsers & "'"
Me.Bookmark = rs.Bookmark

I have tried

Code:
Set rs = Me.Recordset.Clone
rs.FindFirst "[OwnerID] = " & Me![lstUsers] 
Me.Bookmark = rs.Bookmark

Not sure how to fix this issue, any help would be greatly appreciated.
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
pr2-eugin ~ Thank you for the advice, but I know the record is there. they can only select from a listbox of choices, so they can't enter there own data to do the search.
 

namliam

The Mailman - AWF VIP
Local time
Today, 04:39
Joined
Aug 11, 2003
Messages
11,695
Dim RS as Dao.Recordset

Bookmark is a part of a recordset, you need to define your RS as a DAO.Recordset....

NOTE the DAO, to make sure you get a DAO one, not a ADO one.... becuase you will get the same error message if you get an ADO recordset since forms are DAO.
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
Changed to rs As DAO.Recordset and still get he same error.

Now and I am getting no record found.
 

pr2-eugin

Super Moderator
Local time
Today, 03:39
Joined
Nov 30, 2011
Messages
8,494
What is the value you are getting from the Listbox? check that properly.
 

bob fitz

AWF VIP
Local time
Today, 03:39
Joined
May 23, 2011
Messages
4,726
What value/s are shown in message box if you use:
Code:
Msgbox Me.lstUsers & " and " & Me!lstUsers
rs.FindFirst "[OwnerID] = '" & Me![lstUsers] & "'"
Me.Bookmark = rs.Bookmark <
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
Bob I am getting the word:

and

in the msgbox
 

bob fitz

AWF VIP
Local time
Today, 03:39
Joined
May 23, 2011
Messages
4,726
What is the Row Source property of the list box
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
Bob if I change it variable back to

rs as Object

I get lthompson and ltompson in the msgbox
 

bob fitz

AWF VIP
Local time
Today, 03:39
Joined
May 23, 2011
Messages
4,726
Please answer Paul's question post #9 and mine post #10
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
pr2-eugin properties are as follows:

Bound Column 1
Column Count 2 column 1 = OwnerID COlumn 2 = FullName
Column widths = 0";1.5"
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
Bob

Rowsource Property is:

SELECT tblOwner.OwnerID, tblOwner.FullName FROM tblOwner WHERE (((tblOwner.OwnerID)<>"<---SELECT--->"));
 

bob fitz

AWF VIP
Local time
Today, 03:39
Joined
May 23, 2011
Messages
4,726
What result do you get if you use:
EDIT
Code:
[COLOR="red"][B]Dim [COLOR="Red"][B]DAO[/B][/COLOR].rs As Recordset
[/B][/COLOR]
Set rs = Me.Recordset.Clone
Msgbox Me.lstUsers
rs.FindFirst "[OwnerID] = " & Me.[lstUsers]
Me.Bookmark = rs.Bookmark
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
Compile error:

Syntax error

Code:
DAO.rs AS Recordset
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
No current record found '3021', but the msgbox is still showing the names.
 

Bigmo2u

Registered User.
Local time
Yesterday, 21:39
Joined
Nov 29, 2005
Messages
200
If i do:
Code:
rs.FindFirst "[OwnerID] =  " & Str(Me.lstUsers)

I get dataType mismatch
 

bob fitz

AWF VIP
Local time
Today, 03:39
Joined
May 23, 2011
Messages
4,726
And using:
Code:
Dim rs As DAO.Recordset

Set rs = Me.Recordset.Clone
Msgbox Me.lstUsers.Column(0) & " : " & Me.lstUsers.Column(1)
rs.FindFirst "[OwnerID] = " & Me.lstUsers.Column(0)
Me.Bookmark = rs.Bookmark
 

Users who are viewing this thread

Top Bottom