On 31 Jan 2004 19:58:46 -0800,
yamafopa@yahoo.com (yamafopa) wrote:
see comments in-line.
-Tom.
[color=blue]
>Just moving up from Access 97 and trying 2K. I am used to using the
>FindFirst method of the RecordsetClone object in order to do form
>navigation with a combo box. I notice that the wizard in 2K writes the
>following code in order to accomplish this...
>
> ' Find the record that matches the control.
> Dim rs As Object
>
> Set rs = Me.Recordset.Clone
> rs.Find "[req_no] = " & Str(Me![Combo98])
> Me.Bookmark = rs.Bookmark
>
> Set rs = Me.Recordset.Clone
>
>My questions are;
>
>1. Why dim the recordset as Object rather than as ADODB.Recordset?[/color]
Sloppy programming, or late binding. Note that with A2000 for the
first time ADO is the default, rather than DAO,
[color=blue]
>2. Why not use rs.close and/or Set rs = nothing[/color]
Sloppy programming. You're better off closing objects explicitly.
[color=blue]
>
>If if was me doing this I would write...
>
>On Error GoTo EH
>
>Dim rst As ADODB.Recordset
>
>Set rst = Me.Recordset.Clone
>rst.Find "req_no = " & Str(Me!cboRequestCode)
>Me.Bookmark = rst.Bookmark
>rst.Close
>
>SeeYa:
> Set rst = Nothing
> Exit Sub
>
>EH:
> MsgBox Err.Number & " - " & Err.Description
> Resume SeeYa
>
>Comments??
>
>yamafopa![/color]