Avatar of woodje
woodjeFlag for United States of America 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_country_sub_add) on a subform of (f_gu_gdr_entry_country_sub) 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.

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"
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

Open in new window

Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon
Rey Obrero (Capricorn1)

if you are calling the codes in the main form


Me.f_gu_entry.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Visible = True
Me.f_gu_entry.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Enable = True
Rey Obrero (Capricorn1)

your naming of forms and controls  are too long
Rey Obrero (Capricorn1)

oops, it is hard to read the codes


Me.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Visible = True
Me.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Enable = True
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Scott McDaniel (EE MVE )

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.NameOfYourSubformCONTROL.Form.YourCommand.Visible = True



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.cmd_f_gu_gdr_entry_country_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.  
Rey Obrero (Capricorn1)

Me.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Visible = True

Me.f_gu_gdr_entry_country_sub.Form.setfocus   'Add this line

Me.f_gu_gdr_entry_country_sub.Form.cmd_f_gu_gdr_entry_country_sub_add.Enable = True

or if you have any other control , textbox or command button

set the focus to either one of them before enabling


Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Scott McDaniel (EE MVE )

Is "f_gu_gdr_entry_country_sub" 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:


If I instead refer to it as:


Access will throw an error, since there is no control named "frmManagers" on my form.


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.


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.
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question


That did it. LOL One little letter causes that much pain.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck