[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2008-11-13
11
Medium Priority
?
486 Views
Last Modified: 2013-11-28
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
Comment
Question by:njmatt
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 13

Expert Comment

by:wiswalld
ID: 22950244
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
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22950263
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
 
LVL 13

Expert Comment

by:wiswalld
ID: 22950297
Try this sample
sample.mdb
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 13

Expert Comment

by:wiswalld
ID: 22950347
Also I did not have to set focus to the frmprofile to do this.
0
 
LVL 1

Author Comment

by:njmatt
ID: 22950377
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
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22950426
Nice code wiswalld but it errors on an expression on my laptop when clicking button. Using access 2003.
0
 
LVL 13

Expert Comment

by:wiswalld
ID: 22950430
Can you upload the database?
0
 
LVL 13

Expert Comment

by:leegclystvale
ID: 22950456
Back to here?
0
 
LVL 6

Accepted Solution

by:
Gugro earned 1000 total points
ID: 22950652
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
 
LVL 1

Author Comment

by:njmatt
ID: 22950664
I have uploaded a watered down version of the database...I can't figure out why it doesn't work.
IMED-Clean.mdb
0
 
LVL 1

Author Comment

by:njmatt
ID: 22950722
wow..thanks gugro..it was that simple.  

thanks to everyone else as well.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question