MSGBOX problem and Edit button problem

gyan123

New Member
Joined
Sep 9, 2015
Messages
2
Hello............
my problem is with Msgbox.........

Below two codes
1 for searching the data (it is working smoothly.......but i want it gives following message) and 2. is for Modify the data

1. if textbox1 is blank and i hit commandbutton5 it gives a message (msgbox"Please enter an employee code")
2. When An employee code does not exist in Allpayment sheet, it should give a message (msgbox "Employee code does not exist")
3. When an employee code exist in Allpayment sheet, it should give a message (msgbox"Employee Pass")
Code:
[/COLOR][COLOR=#333333]Private Sub CommandButton5_Click()[/COLOR]
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Dim b As Long
Dim l As Range
b = Me.TextBox1.Value
Set l = Sheets("Allpayment").Range("a:a")
s = Application.WorksheetFunction.Match(b, l, 0)
Me.TextBox2.Value = Sheets("Allpayment").Cells(s, 2).Value
Me.TextBox3.Value = Sheets("Allpayment").Cells(s, 1).Value
Me.TextBox4.Value = Sheets("Allpayment").Cells(s, 3).Value
Me.TextBox5.Value = Sheets("Allpayment").Cells(s, 4).Value
Me.TextBox6.Value = Sheets("Allpayment").Cells(s, 5).Value
Me.TextBox7.Value = Sheets("Allpayment").Cells(s, 6).Value
Me.TextBox8.Value = Sheets("Allpayment").Cells(s, 7).Value
Me.TextBox9.Value = Sheets("Allpayment").Cells(s, 8).Value </code>[COLOR=#333333]End Sub[/COLOR][COLOR=#333333]


2. I have also a commandbutton2 (Modify
In some cases i want to Modify the data of an employee code if it exist in "Allpayment" sheet but i am missing something in below code
if above said commandbutton5 shows the data of an employee code if found in "Allpayment", now i want to Modify the data which is displaying in Textbox2 to Textbox9.......when i hit the commandbutton2 it ask me to "are you want to modify the data" if i click Yes ((msgbox "Data updated") it modify the original data) if i click no (move the curser in textbox1 for searching another record)

thats it
Code:
[/COLOR][COLOR=#333333]Private Sub CommandButton2_Click()[/COLOR][COLOR=#333333]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">'edit button coding
Me.TextBox2.Enabled = True
Me.TextBox3.Enabled = True
Me.TextBox4.Enabled = True
Me.TextBox5.Enabled = True
Me.TextBox6.Enabled = True
Me.TextBox7.Enabled = True
Me.TextBox8.Enabled = True
Me.TextBox9.Enabled = True
End Sub</code><code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
</code>
[/COLOR]
[COLOR=#333333]
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top