Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i find and move to a record....

Status
Not open for further replies.

Eric6

Programmer
Jun 11, 2002
54
CA
hello

i want to make a form that onload, moves to the proper record.

the record is identified by a name (name is a PK)
i want the form to open to the record that
matches the name that was given by the openArgs method

thank you in advance
Eric
 


'This move to a given record
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "[TheNameYouAreLookingFor]='" & Me.OpenArgs & "'"
If rst.NoMatch Then
'
Else
Me.Bookmark = rst.Bookmark
End If 'If rst.NoMatch Then
rst.Close

Steve King
'This Filters
If Len(OpenArgs) > 0 Then
Me.Filter = "Name='" & OpenArgs & "'"
Me.FilterOn = True
End If Growth follows a healthy professional curiosity
 
I tried puttin this in my onload event for my form and couldnt get it to work.
Seems to give me error message for these two lines:
Private Sub Form_Load()
rst.FindFirst

[tt]

Private Sub Form_Load()
Dim rst As Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "[proj_poc_fnm]='" & Me.OpenArgs & "'"
If rst.NoMatch Then
'
Else
Me.Bookmark = rst.Bookmark
End If 'If rst.NoMatch Then
rst.Close


'This Filters
If Len(OpenArgs) > 0 Then
Me.Filter = "Name='" & OpenArgs & "'"
Me.FilterOn = True
End If
End Sub [/tt]
 
First of all remove all the section after 'This Filter because it is an alternative to using the recordset. This works fine on my Access 2000 system but I dimensioned the recordset as follows. Since ADO is the default on Access 2000 you need to do the same.

Dim rst As DAO.Recordset

And of course make sure you have the Data Access Objects (DAO) reference set.

Steve King Growth follows a healthy professional curiosity
 


"And of course make sure you have the Data Access Objects (DAO)
reference set"

What is the DAO and how do I get the reference set??
 
This is one of the more common chores when doing development using COM. DAO is the language to access data and contains objects like Database, Recordset, TableDef, Fields, etc. It's is being slowly replaces by ActiveX Data Objects (ADO) which is why you need to explicitly dimension the recordset or your system, by default, will believe it needs to reference the ADO Recordset. The Data Access Objects (DAO) library is most probably on your system already. You just need to let your application know that you want to use it. To do that open a module, any module, in design mode and go to Tools\References. Scan down the list of available reference objects until you come to (probably) 'Microsoft DAO Object Library 3.6'.

Steve King ----------------------
Steve King
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top