Accessing "current record" me!<field> values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a record source function in a form module. The function is called
when the user pulls down a combo box. The form is in DATASHEET view.

this code: msgBox (Me.CurrentRecord & " " & Me.txtNAME.Value) reports:

the number of the CURRENT RECORD (eg: row 25) but the NAME that is in the
FIRST record (eg, the first row in the table)

question: What do I have to do to get Access to supply
the NAME value that is in the "Current" record?

I can't find a property or method that relates to moving a pointer from row
to row in a Datasheet form, but I know such a tool MUST exist. Maybe it's
some form of bookmark? I'm trying everything.

Leonard
 
That's certainly not the behavior I'd expect.
What event of the combobox is this coded on?
What is the ControlSource of txtName?
 
This is a "row source function". It is a defined parameters function
(defined by Access, not by me - you have to look it up in help), the name of
which is entered as the value of the RowSource property of the combobox.

It is called when the pulldown button is clicked. It is coded to return a
set of options for the combobox - thus, the set of options can this be
customized for the environment that exists at the time the control is
activated. But the code needs to be able to evaluate the environment and
Access refuses to provide necessary data.

The independent data, txtNAME, is bound to a field in the underlying table.
That's not the problem.

PS: Obviously, if code like "debug.print me!control1" is placed in an event
function (eg, on_click) of, say, control5, the behavior is as expected: the
user clicks control2 on row 35 and the value of control1 on row 35 is
returned. However, when the same code is placed in the row source function,
the value of control1 on row 1 would be returned. The only relevant
current row info that I seem to be able to access is the row number
(me.currentrecord). I guess I could use that to build SQL, but that seems to
be a ridiculous workaround.

I really need to know more about how Access stores pointers related to a
datasheet form.

I think that any database system should make "value of field x in record n"
easily accessable.
 
Perhaps you can clarify just why you want to use this row source function.
I've been aware of this option for some time, but have never myself seen a
need to use it, rather than just resetting the combobox's rowsource in the
form's OnCurrent event. (Yes, that does reset the rowsource when you move
to the row, even if you don't need to drop it down, but the performance hit
has never seemed significant...)

As for your desire to have "field x in record n" easily accessible, Access
does not natively order the rows in its tables/queries. That's part of why
it's so useful to define a primary key. Then you can easily retrieve field
x for the row with PK n.

HTH
 
Your comments and suggestions are very helpful. I will change my approach to
the problem. There's so much to learn, even after 30+ years of computer
experience, much of it using a much simpler dBase (II to 5) (almost all
self-taught, alas). Thanks for staying with me on this.

Leonard
Berkeley
 
Back
Top