473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error using findfirst

10
I try to use findfirst command and I got error.
Could someone please help me to find the solution:?
My code is as follow

Dim db As Database
Dim rs As Recordset
Dim strCriteria As string


mdate=date-10


Set db = CurrentDb()
MsgBox strCriteria

Set rs = db.OpenRecordset("Calendar")
strcriteria=mdate


rst.FindFirst(strCriteria)' error shown as run-time error 424 object required'
If rst.NoMatch Then
MsgBox "No entry found"
Else
mrdate = hrdproc
End If
Msgbox mrdate


Thank you in advance
Apr 26 '11 #1
5 7421
Mariostg
332 100+
You Dim and Set rs, but use rst...

You should also take the habbit of declaring whether you use DAO or ADODB when you declare recordset.
Apr 26 '11 #2
moepusu
10
Thank you for your advice

I just changed and re-run the program with new criteria since my old criteria doesn't work. Another error shows. please see below


Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strCriteria As string

mdate=date-10

Set db = CurrentDb()
strCriteria = "[rdate] = " & mdate
'strCriteria = mdate

MsgBox strCriteria

Set rst = db.OpenRecordset("Calendar")

With rst
.FindFirst (strCriteria)' error show - runtime error 3251, operation is not supported for this type of object
If rst.NoMatch Then
MsgBox "No entry found"
Else
mrdate = hrdproc
End If
End With
Apr 26 '11 #3
Mariostg
332 100+
I don't use the findFirst featur too often, but it appears you must specify a recordset type dbOpenSnapshot for it to work:
Set rst = db.OpenRecordset("PayList", dbOpenSnapshot)
Apr 26 '11 #4
moepusu
10
Hi
Thank you again, no more error
but, still problem

msgbox strCriteria show as 4/16/2011, since I use mdate=date-10. That is correct.

But when I write the code: msgbox mrdate nothing in there. keep showing "no entry found", Actually supposed to show 4/29/2011 according to my data.
rdate is date structure with index .
Do you have any idea?

Thank you so much
Apr 26 '11 #5
TheSmileyCoder
2,322 Expert Mod 2GB
The thing is when you later try to use the string strCriteria with the findfirst function, it will get evaluated by the JET engine. Thus instead of a date, JET will see it as 4 divided by 16 divided by 2011.

I suggest you look at this insights article here on Bytes, it will tell you all you need to know about the issue.
Literal DateTimes and Their Delimiters (#)
Apr 26 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: rwalker | last post by:
Error number 429 - COM object with CLSID {000209F0-0000-0000-C000-000000000046} is either not valid or not registered. Intermittent occurance of this error. Using Word.Global to run word macro...
4
by: Paolini | last post by:
compiling this using gcc -o xxx xxx.c I obtain this error message in function Main 6 storage size of 'ff' isn't known Can any help me ? #include <stdio.h>
3
by: Andrew Luke | last post by:
Hi all you C++ guru's! I'm 'very, very' new to C++ and I'm having a little trouble configuring my VS environment I think - when I try and compile some sample code I'm getting the following...
2
by: Ian Griffiths | last post by:
I have been given a schema, instances of which I'm required to be able to consume and generate. I'd like to be able to manipulate these instances as DataSets internally in my application. The...
1
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or...
1
by: ns2k | last post by:
I add reference office.dll and Microsoft Office Excel Component to my project and use : --------------------------------------- Dim App As Excel.Application, BarName as String ... Dim Bar As...
11
by: Frankie | last post by:
Hello: New user here...first post to group. I'm getting an SQL syntax error when I try to run the following query: $query = sprintf("SELECT itemNumber, entryDate, modifyDate, thumbnailURL,...
1
Corster
by: Corster | last post by:
I went through a great deal of hassle to figure this out for myself, but now it is complete, I would like to share it with the world! I know afew other people have had trouble with FindFirst and...
4
by: Rick | last post by:
Access2003 in XP I'm using the code below to append any new records from (tbl_From_Mainframe) into (tbl_Appended_Data). It takes more than a minute to search 7000 records for a dozen new records....
0
by: sa6113 | last post by:
I am using this code to connect to a windows machine using paramiko, I have installed sshd on the machine and it works properly: sock.connect((hostname, port)) t = paramiko.Transport(sock)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.