B
Bram van Leur
I've experimented and searched this newsgroup but I still don't have
the answer to this basic question. Although it should be simple I'll
try to explain it thoroughly in the hope others will find this answer.
If I have a textbox on my form which has a vba function as
ControlSource I want to access a recordset with it's cursor positioned
at the record that's being displayed (rendered).
So let's say I have the ControlSource of my control "=PrettyName()"
then
Public Function PrettyName()
PrettyName = Recordset.Fields("code")
End Function
prints a code of some record, but not always the record currently
displayed.
When I manually synchornize the Recordset property using the Bookmark
property
Public Function PrettyName()
Dim rs As ADODB.Recordset
Set rs = Me.Recordset
rs.Bookmark = Me.Bookmark
PrettyName = Recordset.Fields("code")
End Function
it does give the correct value.
But I feel there must be a must more elegant solution to this and not
have to add 4 lines of code for simply accessing a field value of the
current record.
How do I avoid synchronizing every time?
the answer to this basic question. Although it should be simple I'll
try to explain it thoroughly in the hope others will find this answer.
If I have a textbox on my form which has a vba function as
ControlSource I want to access a recordset with it's cursor positioned
at the record that's being displayed (rendered).
So let's say I have the ControlSource of my control "=PrettyName()"
then
Public Function PrettyName()
PrettyName = Recordset.Fields("code")
End Function
prints a code of some record, but not always the record currently
displayed.
When I manually synchornize the Recordset property using the Bookmark
property
Public Function PrettyName()
Dim rs As ADODB.Recordset
Set rs = Me.Recordset
rs.Bookmark = Me.Bookmark
PrettyName = Recordset.Fields("code")
End Function
it does give the correct value.
But I feel there must be a must more elegant solution to this and not
have to add 4 lines of code for simply accessing a field value of the
current record.
How do I avoid synchronizing every time?