0
votes

MS Access 2007, Win 7 32-bits

Is there a way where I can access an open query in datasheet view in access to get the current field value and current field name?

I won't put it into a form since it is a crosstab query and i'd have to generate and get rid of controls dynamically but i'm not fond of messing with forms controls that way with VBA. I know i can put a dynamic column report and bind an event on the controls but I'm asking if there are events or objects that can let me access directly the query.

Perhaps a recordset clone? But I haven't find anything on google.

Of course this is in VBA

Best regards,

2
As in wiki.lessthandot.com/…? While there is a form involved, the crosstab itself is embedded as a query.Fionnuala

2 Answers

1
votes

It may be possible to work around your requirements. The crosstab is contained by a subform:

Source Object : Query.xtab

crosstab

The Control Source for the two textboxes is:

Ctrl   : =[screen].[activecontrol].[name]
Content: =[screen].[activecontrol]

Which means they show which ever column ans column contents the user selects in the crosstab subform. However, they will also show any other selected control on the form. ClickMe does not change the selected control, so the selected items remain the same in the textboxes.

1
votes

You can also enter MacDermott's code for getting the current control's index, so the current control selected on the xtab query subform is displayed dynamically

Public Function ControlIndex(ctl as Control) as long
 Dim i as Integer
  For i=0 to Me.Controls.Count-1
   if me.Controls(i) is ctl then
    ControlIndex=i
   exit for
  end if
  next
 End Function

And finally this can help when changing from one control to another in the same record to keep the textboxes current.