I am trying this:
for each c in me.controls
if typeOf C is textbox then
me.controls(c.tag).visible = true
me.controls(c.tag).setfocus //it crashes
Me.lblMoneyOrder.top = me.txppay1.top
endif
next
How can i set the focus on a report control on the fly?
Trying this code WHERE?
To my knowledge, you cannot set focus to a control in a report, no matter what view it's in, nor can you use SetFocus in Design View on a form.
I get the run-time error 2478 indicating that the application does not allow you to use this method in the current view.
I am trying to load data to the text boxes based on some criteria. I wanted to create the textboxes on the fly but i kept getting errors such as 2147 that does not allow me to create a control on a report unless it is a design view.
You cannot create controls in Access, whether on a form or on a report, unless that form or report is opened in Design View! This is not going to change, no matter how mant times you try to do it.
To be honest, I think the best piece of advice you've gotten was from the person who told you that this wasn't a good idea. I personally consider it to be a horrendously bad idea. Trying to design and balance a report so that it presents data in a clear and professional manner is hard enough with the Design View in front of you. Trying to do it "on the fly" is really inane. You really need to think about designing your form in advance and, as has been suggested both here and elsewhere, making controls visible/invisible depending on your needs.
Welcome to Bytes!
Linq ;0)>