Solved

Command Button Help

Posted on 2000-04-23
1
127 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 50
change vba from autofit to 13.5 width? 4 28
Help me. 3 43
Problem to With line 4 39
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…

919 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

16 Experts available now in Live!

Get 1:1 Help Now