Solved

How to click a command button on another form

Posted on 2014-11-11
20
89 Views
Last Modified: 2014-11-12
i have a command button array of 0 to 7

frmRoofPics.cmdShowPic_Click (7)'this gives an error
frmRoofPics.cmdShowPic_Click 7'this also gives an error

how can i click the 7th command button from another form ?
0
Comment
Question by:isnoend2001
  • 10
  • 10
20 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40435419
frmRoofPics.cmdShowPic(7) = True
0
 

Author Comment

by:isnoend2001
ID: 40435464
Nope error error 438
Object doesn't support this method or property
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40435488
Does frmRoofPics.cmdShowPic(1) = True work? If so then you don't have a control with the index of 7.

BTW this works for me in a little test project.
Form2.Command1(1) = True
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40435504
You could also attach your project and let me take a look at it.
0
 

Author Comment

by:isnoend2001
ID: 40435522
Yes it does have a 7 Heres the code it works when the the buttons are clicked from the same form the buttons are on
Private Sub cmdShowPic_Click(Index As Integer)
        Dim i As Integer
        HidePics
        'For i = 0 To 5
        'picShowPic(i).Visible = False
        'Next
        'picShowPic(Index).Visible = True
        CenterPic (Index)
        'lblShowPic = picShowPic(Index)
  Select Case Index
     Case 0
        lblShowPic = "2 Story Dutch Gable"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
     Case 1
        lblShowPic = "2 different pitches"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
     Case 2
        lblShowPic = "Turit-Formulas"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
     Case 3
        lblShowPic = "Open Center"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
     Case 4
        lblShowPic = "Roof Termology"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
     Case 5
        ' lblShowPic = "5"
         lblShowPic = "Hip-Valley Odd Angles"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
      Case 6
      
      Case 7
       lblShowPic = "Do's Dont's"
        lblShowPic.Left = Me.ScaleWidth / 2 - lblShowPic.Width / 2
'        Me.rtbDoDont.LoadFile
 Case Else
        lblShowPic = "Select an Roof Image"
  End Select
 
End Sub

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 40435539
Project is too huge and too many ocx's, guess i will put a public sub to call
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40435571
Try this little project. Click the "Click Me" button on Form2.
ClickControl.zip
0
 

Author Closing Comment

by:isnoend2001
ID: 40435661
Don't know why mine does not work like your example project
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40435819
What error do you get?
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40435937
Project is too huge and too many ocx's
I don't need the ocx's and if a zip made from the project is too large to upload on EE you can upload it to MediaFire or similar sites and tell me the resulting URL.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:isnoend2001
ID: 40436568
thanks MartinLiss made a public sub to do what the command button did
was just trying to create a shortcut, not a big thing
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40436573
Yes, but don't you want to know why it didn't work so that next time you'll know how to do it?
0
 

Author Comment

by:isnoend2001
ID: 40436617
Not any more, got a million things to do to this project. About 8 yrs ago when first started learning vb i had  to find why something didn't work, but not any more unless i am stuck with no alternative
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40436625
Ok but I'm really curious as to the reason, so as a favor to me, if you have time at all, just zip up your project and post it here or on MediaFire (etc). If you don't have the time don't worry about it. BTW I probably only need the two forms involved in the "click" problem.
0
 

Author Comment

by:isnoend2001
ID: 40436652
From frmHome click huge button to open frmRoofPics click the 7th command button
I found a similar project that i was using for something else
There are tons of ocx's
I put the file here:
http://roofgenius.com/_RoofBids.zip
0
 

Author Comment

by:isnoend2001
ID: 40436679
Martinliss let me know when you have the file so i can delete it
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40436683
OK I have it. And if you like, call me Marty or Martin.
0
 

Author Comment

by:isnoend2001
ID: 40436690
Good I deleted it
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40436703
After commenting out everything except for the cmdShowPic_Click sub in frmRoofPics and the cmdDosDonts_Click sub in frmHome, I don't get any error when I click the button, so I don't know what's going on. Have you tried compiling the app? I ask because there may be other errors that are triggering this one.
0
 

Author Comment

by:isnoend2001
ID: 40437448
Thank Marty I am editing a much larger project, removing tons of functionally and adding some.
The project i sent to you was my attempt to rename the main
form RoofBidder to frmHome the reason:
RoofBidder form had custom ocx menu items that i could not move to  frmHome
i have to much to do at this point to try to compile
When i get everything working i will compile. this usually takes me a day with the compile stopping hundreds of times. i just deal with them one by one if i run into this minor issue again i will try the
code you gave: frmRoofPics.cmdShowPic(7) = True
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now