Solved

Command Button Help

Posted on 2000-04-23
1
129 Views
Last Modified: 2010-05-02
Ok, i'll try to explain what I'm trying to do: I have a visual basic questionaire set up with 4 command buttons.  What I need to do is when the user clicks on one of the buttons the program records the number button that was clicked in another database (eg. Access) and then goes to the next page of the questionaire.   Can anyone help??
0
Comment
Question by:Firestorm042300
1 Comment
 
LVL 5

Accepted Solution

by:
yronnen earned 100 total points
ID: 2741485
Create an array of command buttons (place a command button on the form, mark it with the mouse and choose copy->paste. When VB asks if you want an array say yes, and then choose paste 2 more times).

When you have an array of buttons, they all share the same event code, and the only way that you can know which button was clicked is by using the index propety.

The click event of the buttons can look like that:
Private Sub Command1_Click(Index As Integer)
    SaveValue Index
End Sub

Where SaveValue is the function where you do what you have to do with your app and the index is the number of your button.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

827 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