How to click a command button on another form

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 ?
isnoend2001Asked:
Who is Participating?
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.

Martin LissOlder than dirtCommented:
frmRoofPics.cmdShowPic(7) = True
0
isnoend2001Author Commented:
Nope error error 438
Object doesn't support this method or property
0
Martin LissOlder than dirtCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
You could also attach your project and let me take a look at it.
0
isnoend2001Author Commented:
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
isnoend2001Author Commented:
Project is too huge and too many ocx's, guess i will put a public sub to call
0
Martin LissOlder than dirtCommented:
Try this little project. Click the "Click Me" button on Form2.
ClickControl.zip
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
isnoend2001Author Commented:
Don't know why mine does not work like your example project
0
Martin LissOlder than dirtCommented:
What error do you get?
0
Martin LissOlder than dirtCommented:
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
isnoend2001Author Commented:
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
Martin LissOlder than dirtCommented:
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
isnoend2001Author Commented:
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
Martin LissOlder than dirtCommented:
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
isnoend2001Author Commented:
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
isnoend2001Author Commented:
Martinliss let me know when you have the file so i can delete it
0
Martin LissOlder than dirtCommented:
OK I have it. And if you like, call me Marty or Martin.
0
isnoend2001Author Commented:
Good I deleted it
0
Martin LissOlder than dirtCommented:
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
isnoend2001Author Commented:
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
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
Visual Basic Classic

From novice to tech pro — start learning today.

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.