UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Findfirst Method Not Working In Access 2010, Access 2010    
 
   
foxtrojan
post Oct 30 2019, 10:26 AM
Post#1



Posts: 1,181
Joined: 8-May 06
From: Singapore


Hi. I have been using "FindFirst" method in Access 2003 but cannot use it in access 2010. Any replacement for it?
Go to the top of the page
 
GroverParkGeorge
post Oct 30 2019, 10:30 AM
Post#2


UA Admin
Posts: 36,165
Joined: 20-June 02
From: Newcastle, WA


It should work.

However, we need a lot more detail about where and how you tried to implement it in order to offer suggestions about what might be wrong.


--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
PaulBrand
post Oct 30 2019, 11:06 AM
Post#3



Posts: 1,735
Joined: 4-September 02
From: Oxford UK


Are you referring to FileSearch? If so, the method was deprecated, I have a class to replace it if you need it???

--------------------
Paul
Go to the top of the page
 
foxtrojan
post Oct 30 2019, 11:07 AM
Post#4



Posts: 1,181
Joined: 8-May 06
From: Singapore


All the "Fiindfirst" show below cannot work:-

[1]

Private Sub Form_Load()
On Error GoTo Err_Error_Click
Hide
If Not IsNull(Me.OpenArgs) Then
Dim Rst As Recordset
Set Rst = Me.RecordsetClone
Rst.FindFirst "[SalesDailyID] = " & Me.OpenArgs
If Not Rst.NoMatch Then Me.Bookmark = Rst.Bookmark
Rst.Close
End If
Exit_Error_Click:
Exit Sub
Err_Error_Click:
MsgBox Err.Description
Resume Exit_Error_Click
End Sub


[2]

Function GetLineNumber()
Dim rs As Recordset
Dim CountLines
Dim F As Form
Dim KeyName As String
Dim KeyValue

Set F = Form
KeyName = "SalesDailyID"
KeyValue = [SalesDailyID]

On Error GoTo Err_GetLineNumber
Set rs = F.RecordsetClone
' Find the current record.
Select Case rs.Fields(KeyName).Type
' Find using numeric data type key value.
Case DB_INTEGER, DB_LONG, DB_CURRENCY, DB_SINGLE, _
DB_DOUBLE, DB_BYTE
rs.FindFirst "[" & KeyName & "] = " & KeyValue
' Find using date data type key value.
Case DB_DATE
rs.FindFirst "[" & KeyName & "] = #" & KeyValue & "#"
' Find using text data type key value.
Case DB_TEXT
rs.FindFirst "[" & KeyName & "] = '" & KeyValue & "'"
Case Else
MsgBox "ERROR: Invalid key field data type!"
Exit Function
End Select
' Loop backward, counting the lines.
Do Until rs.BOF
CountLines = CountLines + 1
rs.MovePrevious
Loop
Bye_GetLineNumber: ' Return the result.
GetLineNumber = CountLines
Exit Function
Err_GetLineNumber:
CountLines = 0
Resume Bye_GetLineNumber
End Function

Go to the top of the page
 
foxtrojan
post Oct 30 2019, 11:09 AM
Post#5



Posts: 1,181
Joined: 8-May 06
From: Singapore


Hi PaulBrand, sure, appreciate very much if you have a replacement for it.
Go to the top of the page
 
GroverParkGeorge
post Oct 30 2019, 11:17 AM
Post#6


UA Admin
Posts: 36,165
Joined: 20-June 02
From: Newcastle, WA


What does it mean to say "it cannot work"?

Does it raise an error? Give you wrong results? Something else?

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
GroverParkGeorge
post Oct 30 2019, 11:19 AM
Post#7


UA Admin
Posts: 36,165
Joined: 20-June 02
From: Newcastle, WA


It is true that newer versions of Access are less tolerant of ambiguity, so instead of

Dim Rst As Recordset

Try

Dim Rst As DAO.Recordset

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
PaulBrand
post Oct 30 2019, 11:24 AM
Post#8



Posts: 1,735
Joined: 4-September 02
From: Oxford UK


I think it's on here somewhere...

--------------------
Paul
Go to the top of the page
 
foxtrojan
post Oct 30 2019, 11:30 AM
Post#9



Posts: 1,181
Joined: 8-May 06
From: Singapore


Hi George. pop-up box shows "Compile Error - Method or Data Member not found". This error pops up on all codes with "rst.FindFirst"
Go to the top of the page
 
cheekybuddha
post Oct 30 2019, 01:50 PM
Post#10


UtterAccess Moderator
Posts: 11,857
Joined: 6-December 03
From: Telegraph Hill


Did you make the change that George suggested?

Change:
CODE
Dim Rst As Recordset

to:
CODE
Dim Rst As DAO.Recordset


And:
CODE
Dim rs As Recordset

to:
CODE
Dim rs As DAO.Recordset

--------------------


Regards,

David Marten
Go to the top of the page
 
foxtrojan
post Oct 30 2019, 06:35 PM
Post#11



Posts: 1,181
Joined: 8-May 06
From: Singapore


Hi Guys, it works perfectly. thank you so much
Go to the top of the page
 
GroverParkGeorge
post Oct 31 2019, 08:50 AM
Post#12


UA Admin
Posts: 36,165
Joined: 20-June 02
From: Newcastle, WA


David and I were happy to help.

Continued success with your project.

--------------------
My Real Name Is George. Grover Park Consulting is where I did business for 20 years.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
foxtrojan
post Oct 31 2019, 10:41 PM
Post#13



Posts: 1,181
Joined: 8-May 06
From: Singapore


Thanks George, I need all the help you can give, after 15 years with 2003, I get lost with all the new "ribbons", pane, etc etc. in 2010. No choice have to move forward. Thanks again.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    6th December 2019 - 07:36 AM