Consulting

Results 1 to 7 of 7

Thread: what is wrong with my update button code excel vba

  1. #1
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location

    Exclamation what is wrong with my update button code excel vba

    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

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    you have:
    'goto row
    rowselect = Me.cmbiqama.Value
    'next row
    rowselect = rowselect + 1

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

  3. #3
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    thank you very much. how do i code for the update button?
    what fix should i do?

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    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.

  6. #6
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    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.

  7. #7
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •