Run-Time Error 3983 (1 Viewer)

Bigmo2u

Registered User.
Local time
Today, 08:07
Joined
Nov 29, 2005
Messages
200
Run-time Error: An arguement topdate function was invalid. The field name must be provided as a string value in quotation marks.

I have never got this before. I have this same code on other forms, but using other tables and it works just fine.

Code:
Private Sub lstSearch_AfterUpdate()
Dim rs As DAO.Recordset

Set rs = Me.Recordset.Clone
rs.FindFirst "[ProjectID] = " & Str(Me![lstSearch])
[COLOR="Red"][B]Me.Bookmark = rs.Bookmark[/B][/COLOR] ' This is where Error pops at
Set rs = Nothing

End Sub

The listbox works fine running through the records, but once I change something on the form and click in the listbox to go to a new record it throws run-time error 3983.

ProjectID is a Long Integer

If you need a copy of the DB just let me know.

Thank you for the help with this.
 

Cronk

Registered User.
Local time
Today, 23:07
Joined
Jul 4, 2013
Messages
2,774
What is the rowsource me!lstSearch and which is the bound column?

When was the last time you compacted the db?
 

JHB

Have been here a while
Local time
Today, 15:07
Joined
Jun 17, 2012
Messages
7,732
..
rs.FindFirst "[ProjectID] = " & Str(Me![lstSearch])
..
ProjectID is a Long Integer
Look at the above, you write it is a number type, but you convert it to text.
 

spikepl

Eledittingent Beliped
Local time
Today, 15:07
Joined
Nov 3, 2010
Messages
6,142
Set rs = Me.Recordset.Clone -> Set rs = Me.RecordsetClone

Also

rs.FindFirst "[ProjectID] = " & Str(Me![lstSearch]) ...

if Me!lstSearch holds an integer or a long, is exactly the same as

rs.FindFirst "[ProjectID] = " & Me![lstSearch]

the conversion to string is explicit in the first case and implicit in the second.
 

Cronk

Registered User.
Local time
Today, 23:07
Joined
Jul 4, 2013
Messages
2,774
Keep in mind though that CStr() does not give the same result as Str(). The function Str() converts the implied plus in front of a number into a blank.

Try it.
Code:
? len(str(9)) 
2

? "x" & str(9) & "x"
x 9x

? cstr(9) = str(9)
False
 

spikepl

Eledittingent Beliped
Local time
Today, 15:07
Joined
Nov 3, 2010
Messages
6,142
Str is very useful for inputting decimal numbers into SQL constructed in VBA, in that it always uses "." as decimal separator (which is required by SQL), irrespective of locale settings.

So myDecimalNumber will wreak havoc in environments with "," as separator, whereas Str(myDecimalNumber) will yield a string containing a decimal number with "." as separator.
 

Users who are viewing this thread

Top Bottom