Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 38 of 38

Thread: my excel vba stop running when i run the userform and not responding

  1. #21
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    As I said, step through the sub checking each step. Clearly this isn't correct:

    Cells(rowselect, 7) = Me.ComboBox2.Value 
    Cells(rowselect, 7) = Me.textBASICSALARY.Value
    But that is not the problem you are experiencing. The code you've posted doesn't really tell us much. What value is in me.cmbiqama?
    Semper in excretia sumus; solum profundum variat.

  2. #22
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Private Sub cmbiqama_Change()
    
    Dim i As Long, LastRow As Long, ws As Worksheet
    Set ws = Sheets("sheet3")
    LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
    
    For i = 2 To LastRow
     If Val(Me.cmbiqama.Value) = ws.Cells(i, "B") Then
      Me.Textempnum = ws.Cells(i, "B").Value
      Me.txtiqama = ws.Cells(i, "C").Value
      Me.txtemployeename.Value = ws.Cells(i, "D").Value
      Me.ComboBox1 = ws.Cells(i, "E").Value
      Me.cmbxcountry = ws.Cells(i, "F").Value
      Me.textBASICSALARY = ws.Cells(i, "G").Value
      Me.textOVERTIME = ws.Cells(i, "H").Value
      Me.textFOOD = ws.Cells(i, "I").Value
      Me.textTRANS = ws.Cells(i, "J").Value
      Me.textOTHERS = ws.Cells(i, "K").Value
      Me.txtemployer = ws.Cells(i, "W").Value
      Me.ComboBox2 = ws.Cells(i, "X").Value
      
      
    End If
    Next i
    
    
    End Sub
    
    
    
    
    
    
    
    Private Sub UserForm_Initialize()
     
     
    Dim i As Long, LastRow As Long, ws As Worksheet
    Set ws = Sheets("Sheet3")
    LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
    For i = 2 To LastRow
    Me.cmbiqama.AddItem ws.Cells(i, "B").Value
    Next i



    this is the value

  3. #23
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    
    Dim IQAMANo As String
    
    
    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


    my recoded update button still not working

  4. #24
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    this is the value
    I don't see a value?

    I you are not sure how to get this put this line:

    MsgBox IQAMANo
    in between these two lines:

    IQAMANo = Me.cmbiqama.Value 
     
     
     
    With Sheet3.Rows(IQAMANo)
    Semper in excretia sumus; solum profundum variat.

  5. #25
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Quote Originally Posted by paulked View Post
    I don't see a value?

    I you are not sure how to get this put this line:

    MsgBox IQAMANo
    in between these two lines:

    IQAMANo = Me.cmbiqama.Value 
     
     
     
    With Sheet3.Rows(IQAMANo)
    my values are based on the combo box.
    I populate textbox and others using combo box value based on the database.
    the value is on the date base B column the ID number. populate using combox

  6. #26
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    i have uploaded the filrfor reference
    Attached Files Attached Files

  7. #27
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    jouna payroll-Ked (1).xlsm

    It worked for me!

    I'm the new employee at the bottom of the list.
    Semper in excretia sumus; solum profundum variat.

  8. #28
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Quote Originally Posted by paulked View Post
    jouna payroll-Ked (1).xlsm

    It worked for me!

    I'm the new employee at the bottom of the list.


    welcome to my company paul

    the register button works but the update button does not work as it should be

  9. #29
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    jouna payroll-Ked (1).xlsm

    The update worked too. I updated myself and there I am, row 513 sheet5.
    Semper in excretia sumus; solum profundum variat.

  10. #30
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Quote Originally Posted by paulked View Post
    jouna payroll-Ked (1).xlsm

    The update worked too. I updated myself and there I am, row 513 sheet5.

    it should update the current data of employee but it will create another same data in the other row

  11. #31
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Private Sub cmdupdate_Click()
        Dim IQAMANo As Integer
        If Me.cmbiqama.Value = "" Then
            MsgBox "IQAMA No Can Not be Blank!!!", vbExclamation, "IQAMA No"
            Exit Sub
        End If
        IQAMANo = Me.cmbiqama.Value
        Sheet5.Select
        Dim rowselect As Double
        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, 24) = Me.ComboBox2.Value
    End Sub
    This is the update code. It is only updating Sheet5.

    It still has the error I pointed out in post 21.
    Semper in excretia sumus; solum profundum variat.

  12. #32
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Employee Data General Business Rules:
    Data must be archived forever
    Employee numbers are never reused

    Therefore using Row numbers for employee numbers will not work at all times.

    Dim Found as Range
    Set Found = Sheet5.Range("B:B").Find(Textempnum)
    If not Found is nothing then
    rowselect = Found.Row
    Else
    RowSelect = Sheet5.Cells(Rows.Count, "B").End(xlUp).Row + 1
    End if
    
    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.cmbxcoRows(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.cmbxco.........................
    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

  13. #33
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Quote Originally Posted by SamT View Post
    Employee Data General Business Rules:
    Data must be archived forever
    Employee numbers are never reused

    Therefore using Row numbers for employee numbers will not work at all times.

    Dim Found as Range
    Set Found = Sheet5.Range("B:B").Find(Textempnum)
    If not Found is nothing then
    rowselect = Found.Row
    Else
    RowSelect = Sheet5.Cells(Rows.Count, "B").End(xlUp).Row + 1
    End if
    
    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.cmbxcoRows(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.cmbxco.........................




    Thank you very very much!!!

    it worked perfectly. thank you so so much

  14. #34
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    its possible to print data grid list box?

  15. #35

  16. #36
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Quote Originally Posted by paulked View Post
    Attachment 21498

    1,048,559 rows for employees? That's quite a big company.

    I've shrunk your table to fit the data you have in it leaving a few columns for future.

    I've taken out the 2 Global Dim's that are causing confusion.

    I've removed the picture, pretty as it was, from sheet 4 to make the file size fit here. You can put that back in by all means.

    I've taken out the DoEvents which was superfluous.

    The form will open now, but i couldn't view all of it because of its size.



    NOT RESPONDING AGAIN PLEASE HELP PAULKED

    THANK YOU VERY MUCHjouna payroll.xlsm

  17. #37
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Are you satisfied with the solution?

    Do you need more help?
    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

  18. #38
    VBAX Regular
    Joined
    Jan 2018
    Posts
    40
    Location
    Quote Originally Posted by SamT View Post
    Are you satisfied with the solution?

    Do you need more help?
    Yes, i am very satisfied. thank you very to you all.


    Yes, I do need more help in VBA excel, I'm still learning excel
    can you help me? please

    thank you very much in advance.


    because of you guys in learning many thanks to you all, no words can express.

Posting Permissions

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