Solved

executing an access command button from VB5.0

Posted on 1998-07-15
5
161 Views
Last Modified: 2010-05-03
I want to write code that execute a command button from VB.


I've tried this:

db.Form1!Command1.Value = -1

nothing seems to work.  What is the correct way to do this?

Thanks
0
Comment
Question by:dhill10358
5 Comments
 
LVL 2

Expert Comment

by:lortega
ID: 1465849
please explain the question!
0
 

Author Comment

by:dhill10358
ID: 1465850
I thought it was pretty straight forward.  For example when I click a button on a form in VB5.  it will open the access database and  "click" the command button on the access database.  

Thanks

0
 

Expert Comment

by:biko071598
ID: 1465851
If you want it to click a button on an access form, make sure the button has a hot key assigned to it and then use appactivate and sendkeys to 'click' the button.
0
 
LVL 2

Accepted Solution

by:
swilt earned 40 total points
ID: 1465852
Put this in the code module for Command1

Public Sub BuzzCommand1()
    Command1_Click
End Sub

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    MsgBox "hello"

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
   
End Sub


Then just call the sub
db.Form1.BuzzCommand1

p.s. you cannot call Command1_Click directly because it is Private
0
 
LVL 2

Expert Comment

by:mtoft
ID: 1465853
Or you could simple change the declaration from

Private Sub Command1_Click()
 ' something
End Sub

to

Public Sub Command1_Click()
    MsgBox "YO"
End Sub


Then the call would be like:
db.Form1.Command1_Click



Not very nice, but hey - its basic and it works :)
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

803 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