I am trying to change the contents of a text box in Access 2007 at the
format event of a report using the following:
***********
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
txtWeekDay.Text = "tested"
End Sub
*************
If I do this when running print review I get the followng error message:
"You can't reference a method or property for a control unless the control
has the focus"
If I then add to the code as follows
*********
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
txtWeekDay.SetFocus
txtWeekDay.Text = "tested"
End Sub
***********
I then get the error message:
"Microsoft access does not allow you to use this method in the current view"
I suppose I am missing something obvious but I cannot see it so I would be
most grateful for advice,
Best wishes, John Morgan
Lose the dot-Text. It is rarely used in Access and you are seeing why. In
Access we use the Value property, not the Text property and since Value is
the default property you don't even need to mention it in your code...
txtWeekDay = "tested"
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Me.txtWeekDay = "tested"
Note, it is always best to qualify your control references.
--
Dave Hargis, Microsoft Access MVP
I think that also solves the puzzling problem I had of being requested
to set a control focus in code behind a form.
Your help is much appreciated,
Best wishes, John Morgan
On Fri, 21 Mar 2008 13:12:33 GMT, "John m" <j...@woodlander.co.uk>
wrote: