woodje
asked on
Enable command button in subform after update event on main form.
I have a main form f_gu_gdr_entry that has a phone number text box. When you enter a phone number and tab out or press enter an after update event is fired and the form populates. I am trying to have a command button (cmd_f_gu_gdr_entry_countr y_sub_add) on a subform of (f_gu_gdr_entry_country_su b) become visible and enabled. Right now when I run the search no error is returned however the button remains not visible and not enabled. I have listed the code below. Any help you can give me would be great. Thanks.
Jeff
Jeff
DoCmd.ApplyFilter "", "[Forms]![f_gu_gdr_entry]![txtmdnsearch]=[tblglobaldataroaming]![mdn]"
Forms!f_gu_gdr_entry!txtmdn = Forms!f_gu_gdr_entry!txtmdnsearch
DoCmd.GoToControl "txtregion"
Forms!f_gu_gdr_entry.f_gu_gdr_entry_usage_sub.Requery
If user.AccessID = 1 Or user.AccessID = 3 Or user.AccessID = 7 Or user.AccessID = 13 Then
Forms!f_gu_entry.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Visible = True
Forms!f_gu_entry.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Enable = True
End If
woodje,
your naming of forms and controls are too long
your naming of forms and controls are too long
oops, it is hard to read the codes
use
Me.f_gu_gdr_entry_country_ sub.Form.c md_f_gu_gd r_entry_co untry_sub_ add.Visibl e = True
Me.f_gu_gdr_entry_country_ sub.Form.c md_f_gu_gd r_entry_co untry_sub_ add.Enable = True
use
Me.f_gu_gdr_entry_country_
Me.f_gu_gdr_entry_country_
I agree with Cap: Your object names are way too long and convoluted to have any real meaning.
Note also that you must reference the Subform CONTROL that is being used on the main form. This may or may not be named the same as the form you're using as a Subform, but you must refer to it correctly:
Me.NameOfYourSubformCONTRO L.Form.You rCommand.V isible = True
Note also that you must reference the Subform CONTROL that is being used on the main form. This may or may not be named the same as the form you're using as a Subform, but you must refer to it correctly:
Me.NameOfYourSubformCONTRO
ASKER
Cap,
Thanks for the info. The command button is now visible however I am getting a Run-time error '438':
Object doesn't support this property or method
This is occuring on the line:
Me.f_gu_gdr_entry_country_ sub.Form.c md_f_gu_gd r_entry_co untry_sub_ add.Enable = True
I labeled the forms with this structure.
f = form
gu= global usage
gdr = global data roaming
entry = is the entry form
country = is the type of subform
sub = subform.
Then the control is as follows
cmd = command button
then the same for all till you get to country sub form.
Thanks for the info. The command button is now visible however I am getting a Run-time error '438':
Object doesn't support this property or method
This is occuring on the line:
Me.f_gu_gdr_entry_country_
I labeled the forms with this structure.
f = form
gu= global usage
gdr = global data roaming
entry = is the entry form
country = is the type of subform
sub = subform.
Then the control is as follows
cmd = command button
then the same for all till you get to country sub form.
Me.f_gu_gdr_entry_country_
Me.f_gu_gdr_entry_country_
Me.f_gu_gdr_entry_country_
or if you have any other control , textbox or command button
set the focus to either one of them before enabling
cmd_f_gu_gdr_entry_country
Is "f_gu_gdr_entry_country_su b" the name of your Subform CONTROL, or is it the name of the Form that you're using as a Subform? They may be the same, but in many cases they are not ... the error you're getting is strongly indicative of improper syntax.
In the image below, the Subform CONTROL that I'm using is named "sfManagers" ... however, the Form that is being used as a subform in named "frmManagers". In this case, I'd refer to it as such:
Me.sfManagers.Form.SomeCon trol
If I instead refer to it as:
Me.frmManagers.Form.SomeCo ntrol
Access will throw an error, since there is no control named "frmManagers" on my form.
SubformControl.jpg
In the image below, the Subform CONTROL that I'm using is named "sfManagers" ... however, the Form that is being used as a subform in named "frmManagers". In this case, I'd refer to it as such:
Me.sfManagers.Form.SomeCon
If I instead refer to it as:
Me.frmManagers.Form.SomeCo
Access will throw an error, since there is no control named "frmManagers" on my form.
SubformControl.jpg
ASKER
Cap,
I added your first example and get the same results. And when I setfocus to a combo box in the subform then try and enable the button I get the same thing.
LSM,
My subform control name and the form that makes the subform are the same name. I have checked the spelling of both the control name and the subform several times. Thanks for the suggestions.
I added your first example and get the same results. And when I setfocus to a combo box in the subform then try and enable the button I get the same thing.
LSM,
My subform control name and the form that makes the subform are the same name. I have checked the spelling of both the control name and the subform several times. Thanks for the suggestions.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cap,
That did it. LOL One little letter causes that much pain.
That did it. LOL One little letter causes that much pain.
use
Me.f_gu_entry.f_gu_gdr_ent
Me.f_gu_entry.f_gu_gdr_ent