Enable Visible Property of Command Button through OnClick of Button on Separate Form

I have "frmVendor" which has a subform on it "frmVendorAssignment_qry_subform".  Within the "frmVendorAssignment_qry_subform", I have a hyperlink on a person's name.  When that hyperlink is clicked, it opens up "frmProfile" (that persons profile).

On "frmProfile", I have cmdClose (Visible = No).  I only need that button visible when "frmProfile" opens from the Vendor subform.  

The code I have on the hyperlink is:

    DoCmd.OpenForm "frmProfile", , , "[person_key] = " & person_key, , acDialog
    Forms!frmProfile.cmdClose.Visible = True

It does open frmProfile to that person's profile, however, when I force a close on "frmProfile", I get the error message:

Run-time error '2450': 'DatabaseName" can't find the form "frmProfile" referred to in a macro expression or Visual Basic Code.

Thanks in advance.

LVL 1
njmattAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wiswalldCommented:
From for Vendor

DoCmd.Openform "frmprofile"
Forms!frmprofile.command1.visible = true

Set the buttons visible property to false
This way the button is only made visible when opened from frmvendor

Change command1 to the name of the button

After reviewing your code and trying myself it should work fine. Maybe the name of the button is wrong.
0
leegclystvaleCommented:
Can you not bring setfocus/getfocus on the frmprofile, do your visible=true event then setfocus back to the frmprofile?
Bit rough and ready maybe? but I'm sure it wold work. What makes you think I'm not exactly an expert on this :o)
0
wiswalldCommented:
Try this sample
sample.mdb
0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

wiswalldCommented:
Also I did not have to set focus to the frmprofile to do this.
0
njmattAuthor Commented:
Thank you for all your replies.  I ensured that the syntax is correct, I still get the same message.

Would it have anything to do with the fact that the command button I'm trying to make visible is in the Form header?
0
leegclystvaleCommented:
Nice code wiswalld but it errors on an expression on my laptop when clicking button. Using access 2003.
0
wiswalldCommented:
Can you upload the database?
0
leegclystvaleCommented:
Back to here?
0
GugroCommented:
You opend your form with the  acDialog option set !!!!
So your code will only proceed AFTER the form is closed
so when your code
  Forms!frmProfile.cmdClose.Visible = True
runs, the form is already closed !!!

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
njmattAuthor Commented:
I have uploaded a watered down version of the database...I can't figure out why it doesn't work.
IMED-Clean.mdb
0
njmattAuthor Commented:
wow..thanks gugro..it was that simple.  

thanks to everyone else as well.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.