Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Cmdbutton_edit_Click()
- Dim iRow As Long
- Dim ws As Worksheet
- Set ws = Worksheets("Sheet1")
- 'find first empty row in database
- iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
- 'check for a Name number
- If Trim(Me.TextBox_CN.Value) = "" Then
- Me.TextBox_CN.SetFocus
- MsgBox "Please complete the form"
- Exit Sub
- End If
- 'copy the data to the database
- ws.Cells(iRow, 1).Value = Me.Question1.Value
- ws.Cells(iRow, 2).Value = Me.Question2.Value
- ws.Cells(iRow, 3).Value = Me.Question3.Value
- ws.Cells(iRow, 4).Value = Me.Question4.Value
- ws.Cells(iRow, 5).Value = Me.Question5.Value
- ws.Cells(iRow, 6).Value = Me.Question6.Value
- ws.Cells(iRow, 7).Value = Me.Question7.Value
- MsgBox "Data edited", vbOKOnly + vbInformation, "Data Added"
- 'clear the data
- Value = Me.Question1.Value
- Value = Me.Question2.Value
- Value = Me.Question3.Value
- Value = Me.Question4.Value
- Value = Me.Question5.Value
- Value = Me.Question6.Value
- Value = Me.Question7.Value
- Me.TextBox_CN.SetFocus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement