ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add/View/Update/Delete buttons (https://www.excelbanter.com/excel-programming/371950-add-view-update-delete-buttons.html)

[email protected]

Add/View/Update/Delete buttons
 
New to excel vba for userforms. I have a userform with two labels and
two textboxes. Label for Membership number (name=lMemNo), Label for
Name of the Distributor (name=lDistributor) Textbox for Membership
number (name=txtMemNo), Textbox for Name of the Distributor
(name=txtDistributor) and I have Six buttons Add (name=bAdd) View
(name=bView) Update (name=bUpdate) Delete (name=bDelete) Save
(name=bSave) and Show (name=bShow)

I need some of the macro experts to write small codes for each of these
buttons.

On form activate, both textboxes should be disabled.

If anybody clicks on Add button, both textboxes should be enabled,
after user enters values for txtMemNo and txtDistributor and clicks on
bSave, it should find the last row in sheet2 and save the values in the
textbox in column A and B respectively.

If anybody clicks on View button, only txtMemNo button should be
enabled. After entering a membership number, and clicking on bShow
button, it should show the respective name of the distributor in the
txtDistributor textbox (Disabled).

If anybody clicks on Update button, both textboxes should be enabled,
after user enters values for txtMemno, it should show the respective
name of the distributor in the txtDistributor texbox (Enabled). After
making any changes to either textbox and clicking on bSave, it should
change the previous record listed in the excel file with this new one.

If anybody clicks on Delete, only txtMemno button should be enabled.
After entering a membership number, it should promt "Are you sure you
want to delete - Yes/No" If Yes, delete it from the worksheet.

I tried searching some templates/samples on google but could not find
any.

Note: I have two sheets on my workbook. Sheet1 and Sheet2. I have kept
Sheet1 blank with gridlines off so that when the form is active, it
displays blank sheet behind. I want all my data in sheet2 and during
execution of any code, sheet2 should not be displayed. I don't want to
show my records to the user behind the form.

Sandy



Mark Driscol[_2_]

Add/View/Update/Delete buttons
 
The forum is really a place to ask specific questions. When you say

I need some of the macro experts to write small codes for each of these
buttons.


I don't know that you will get much response when it isn't apparent how
much effort you have put in yourself. What you are asking is for
someone to do the work for you. There are many good books where you
can learn about these things, such as one of John Walkenbach's Power
Programming for Excel books.

Mark

wrote:
New to excel vba for userforms. I have a userform with two labels and
two textboxes. Label for Membership number (name=lMemNo), Label for
Name of the Distributor (name=lDistributor) Textbox for Membership
number (name=txtMemNo), Textbox for Name of the Distributor
(name=txtDistributor) and I have Six buttons Add (name=bAdd) View
(name=bView) Update (name=bUpdate) Delete (name=bDelete) Save
(name=bSave) and Show (name=bShow)

I need some of the macro experts to write small codes for each of these
buttons.

On form activate, both textboxes should be disabled.

If anybody clicks on Add button, both textboxes should be enabled,
after user enters values for txtMemNo and txtDistributor and clicks on
bSave, it should find the last row in sheet2 and save the values in the
textbox in column A and B respectively.

If anybody clicks on View button, only txtMemNo button should be
enabled. After entering a membership number, and clicking on bShow
button, it should show the respective name of the distributor in the
txtDistributor textbox (Disabled).

If anybody clicks on Update button, both textboxes should be enabled,
after user enters values for txtMemno, it should show the respective
name of the distributor in the txtDistributor texbox (Enabled). After
making any changes to either textbox and clicking on bSave, it should
change the previous record listed in the excel file with this new one.

If anybody clicks on Delete, only txtMemno button should be enabled.
After entering a membership number, it should promt "Are you sure you
want to delete - Yes/No" If Yes, delete it from the worksheet.

I tried searching some templates/samples on google but could not find
any.

Note: I have two sheets on my workbook. Sheet1 and Sheet2. I have kept
Sheet1 blank with gridlines off so that when the form is active, it
displays blank sheet behind. I want all my data in sheet2 and during
execution of any code, sheet2 should not be displayed. I don't want to
show my records to the user behind the form.

Sandy




All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com