PDA

View Full Version : what is wrong with my update button code excel vba



Aihmar
01-31-2018, 05:56 AM
Hi

Good Day!

this is my code for update button. did not work as it should intended with.
insted of updating the current row of the date. it goe's like adding new row and data is added there.

thank you in advanced for all of youre help







Dim IQAMANo As Integer

If Me.cmbiqama.Value = "" Then

MsgBox "IQAMA No Can Not be Blank!!!", vbExclamation, "IQAMA No"



End If

IQAMANo = Me.cmbiqama.Value

Sheet3.Select

Dim rowselect As Integer

rowselect = Me.cmbiqama.Value

rowselect = rowselect + 1

Rows(rowselect).Select

Cells(rowselect, 2) = Me.Textempnum.Value

Cells(rowselect, 3) = Me.txtiqama.Value
Cells(rowselect, 4) = Me.txtemployeename

Cells(rowselect, 5) = Me.ComboBox1.Value
Cells(rowselect, 6) = Me.cmbxcountry.Value
Cells(rowselect, 7) = Me.ComboBox2.Value
Cells(rowselect, 7) = Me.textBASICSALARY.Value
Cells(rowselect, 9) = Me.textFOOD.Value
Cells(rowselect, 10) = Me.textTRANS.Value
Cells(rowselect, 11) = Me.textOTHERS.Value
Cells(rowselect, 8) = Me.textOVERTIME.Value
Cells(rowselect, 13) = Me.txtab.Value
Cells(rowselect, 14) = Me.txtlate.Value
Cells(rowselect, 15) = Me.txtloan.Value
Cells(rowselect, 16) = Me.txtpenalty.Value
Cells(rowselect, 17) = Me.lbldeduc.Caption
Cells(rowselect, 19) = Me.lblGROSSPAY.Caption
Cells(rowselect, 20) = Me.lblnetpay.Caption

Cells(rowselect, 23) = Me.txtemployer.Value
Cells(rowselect, 24) = Me.ComboBox2.Value

ranman256
01-31-2018, 06:15 AM
you have:
'goto row
rowselect = Me.cmbiqama.Value
'next row
rowselect = rowselect + 1

why rowselect+1....?
to me, that would goto the next row.

Aihmar
01-31-2018, 01:14 PM
thank you very much. how do i code for the update button?
what fix should i do?

SamT
01-31-2018, 02:57 PM
IQAMANo = Me.cmbiqama.Value

With Sheet3.Rows(IQAMANo)
.Cells(2) = Me.Textempnum.Value
.Cells(3) = Me.txtiqama.Value
.Cells(4) = Me.txtemployeename
.Cells(5) = Me.ComboBox1.Value
.Cells(6) = Me.cmbxcountry.Value
.Cells(etc
.
.
.
End with

Aihmar
01-31-2018, 11:31 PM
Dim IQAMANo As Double



IQAMANo = Me.cmbiqama.Value



With Sheet3.Rows(IQAMANo)

.Cells(1) = Me.lblPayref.Caption
.Cells(2) = Me.Textempnum.Value
.Cells(3) = Me.txtiqama.Value
.Cells(4) = Me.txtemployeename.Value
.Cells(5) = Me.ComboBox1.Value
.Cells(6) = Me.cmbxcountry.Value
.Cells(7) = Me.textBASICSALARY.Value
.Cells(8) = Me.textOVERTIME.Value
.Cells(9) = Me.textFOOD.Value
.Cells(10) = Me.textTRANS.Value
.Cells(11) = Me.textOTHERS.Value
.Cells(13) = Me.txtab.Value
.Cells(14) = Me.txtlate.Value
.Cells(15) = Me.txtloan.Value
.Cells(16) = Me.txtpenalty.Value
.Cells(17) = Me.lbldeduc.Caption

.Cells(19) = Me.lblGROSSPAY.Caption
.Cells(20) = Me.lblnetpay.Caption

.Cells(22) = Me.lblpayd.Caption
.Cells(23) = Me.txtemployer.Value
.Cells(24) = Me.ComboBox2.Value



End With






still going to other row 319 corresspondingto the employee number and not to the original located at row166.:crying::crying::crying::crying::help:help:help:help:help:help:help: help

Aihmar
02-01-2018, 12:28 AM
i have removed the rowselect = rowselect+1.
still the same results. i should go to row 166 but i goes 319 coressponding to his employee number adding new data.

SamT
02-01-2018, 09:25 AM
319 coressponding to his employee number
What Form Control contains the Employee number?


nsted of updating the current row of the date.
What Form Control contains the Date?


i should go to row 166
How do you concert a Date to 166?