• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

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.

0
njmatt
Asked:
njmatt
  • 4
  • 3
  • 3
  • +1
1 Solution
 
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 4
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now