code example

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

I have the following code. I can not get a value for
recnbr. I have tried absoluteposition and bookmark.
Neither work for me.

Public Function passfind(strname As Variant, strwhat As
Variant, strwhere As Variant)

Dim recnbr As Integer

Set rst = CurrentDb.OpenRecordset(strname)
rst.Index = strwhere
rst.Seek "=", strwhat

If rst.NoMatch Then
msgbox ("Did not work")
Else

'recnbr = the row that the recordset is at

DoCmd.Close acForm, "whatwhere", acSaveNo

DoCmd.GoToRecord acDataForm, strname, acGoTo, recnbr

End If
End Function
 
I have the following code. I can not get a value for
recnbr. I have tried absoluteposition and bookmark.
Neither work for me.

Tables don't really have record numbers. Where a record appears depends
totally on the GROUP BY clause in the query; an unsorted table can cough up
in any old order at all. The use of index and seek methods suggest you came
up through the old file managers like dBase and its friends.

In a modern dbms, you might like to think about using the db engine to help
you. You could base the form on a query with a

WHERE MyField = SomeValue

so it only has to fetch one record at a time. The Filter property works
similarly. If for some reason you feel you have to load the entire table,
you can use the Bookmark property to move the form's record pointer where
you want it to go.

Hope that helps


Tim F
 
Good observation. I am used to using FoxPro. I was hoping
to be able to move the record displayed on the form by the
record number returned from the seek. Common practice in
the old days. I guess now, I will have to replace each
field on the form with the current value of the recordset
after the seek. I have had absolutely no luck getting a
bookmark to return anything other than a "?"
 
bob said:
Good observation. I am used to using FoxPro. I was hoping
to be able to move the record displayed on the form by the
record number returned from the seek. Common practice in
the old days. I guess now, I will have to replace each
field on the form with the current value of the recordset
after the seek. I have had absolutely no luck getting a
bookmark to return anything other than a "?"

Bookmark? Record number? Replace values?

setting the bookmark property of the form to that of a Recordset
variable synchronizes them. That is, bound fields get updated automatically.
 
bob said:
so... something like this should work ??

form.bookmark = rst.bookmark ??

Right. That is, as long as the rst is some kind of form.recordsetclone ;-)
 
I guess now, I will have to replace each
field on the form with the current value of the recordset
after the seek.

Doesn't Access do this anyway -- it has done for me for the last ten years
on so..?

Tim F
 
Not if your fields are unbound...

Only my imagination... but why would anyone buy an Access license and then
manage all record navigation on unbound forms? Do you think he(?) drugs his
dog and barks at burglars himself too?

All the best



Tim F
 
Tim said:
Only my imagination... but why would anyone buy an Access license and then
manage all record navigation on unbound forms? Do you think he(?) drugs his
dog and barks at burglars himself too?

No idea, but the OP mentioned FoxPro which gave me quite a start. They
draw rectangles themselves, those programmers, with four lines. They
even have to manage button look behavior themselves (I was told).

Maybe I am exaggerating (a bit ;-) ) but I allow for a lot of
possibilities...
 
Back
Top