G
Guest
Hi all, I would appreciate any thoughts on this small problem.
First, a specific coding question:
dim frm as Form
dim ctl as Control
sub Disable()
Set frm = New Form_Form2
for each ctl in frm
If ctl.Name <> Screen.ActiveControl.Name Then
'you can't disable the button with the focus
If ctl.ControlType = acCommandButton Then
frm.ctl.enabled = false
'this is where the problem is
'if you substitute the actual names of a form and a
control, it works
'but it doesn't work as variables. So I've got some
'syntax or conceptual problem here.
end if
end if
next ctl
end sub
Second, a more general question as to what I'm trying to do. I'm opening a
document in Word with Automation from an Access form, and I'm using
WithEvents to monitor from Access what's happening in the Word document. But
I don't want the user to be able to exit from the Access form until the Word
document is closed. It seems the easiest way is simply to disable all the
Command Buttons while Word is open. I'm sure this would work if I enumerate
each button specifically, but I'd like to generalize it so that I can call it
from any form I want to "freeze."
Thank you.
First, a specific coding question:
dim frm as Form
dim ctl as Control
sub Disable()
Set frm = New Form_Form2
for each ctl in frm
If ctl.Name <> Screen.ActiveControl.Name Then
'you can't disable the button with the focus
If ctl.ControlType = acCommandButton Then
frm.ctl.enabled = false
'this is where the problem is
'if you substitute the actual names of a form and a
control, it works
'but it doesn't work as variables. So I've got some
'syntax or conceptual problem here.
end if
end if
next ctl
end sub
Second, a more general question as to what I'm trying to do. I'm opening a
document in Word with Automation from an Access form, and I'm using
WithEvents to monitor from Access what's happening in the Word document. But
I don't want the user to be able to exit from the Access form until the Word
document is closed. It seems the easiest way is simply to disable all the
Command Buttons while Word is open. I'm sure this would work if I enumerate
each button specifically, but I'd like to generalize it so that I can call it
from any form I want to "freeze."
Thank you.