Solved

How to click a command button on another form

Posted on 2014-11-11
20
90 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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
 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i unlock a picture file that was loaded in a picturebox in visual c#? 4 95
VB6 - Convert HH:MM into Decimal 8 56
Visual Studio 2005 text editor 10 39
vbModal 12 53
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

832 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