Solved

How to click a command button on another form

Posted on 2014-11-11
20
87 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 45

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 45

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 45

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 45

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 45

Expert Comment

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

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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 45

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 45

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 45

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 45

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

762 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

21 Experts available now in Live!

Get 1:1 Help Now