Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
where does it go wrong?
hH everybody,
I'm trying to make a UserForm, so the user can easily gave the information for the worksheet. But what am I doing wrong, or what do I forget, because the filled in information will not be copied to the worksheet if you use the commandbutton. This is my code; Option Explicit Private Sub cmdAdd_Click() Dim iRow As Long 'find first empty row in database iRow = wksBlad1.Cells(Rows.Count, 1) .End(xlUp).Offset(1, 0).Row 'check for afdeling If Trim(Me.TextBoxAfd.Value) = "" Then Me.TextBoxAfd.SetFocus MsgBox "Voer een afdeling in" Exit Sub End If 'copy the data to the database With wksBlad1 .Cells(iRow, 1).Value = Me.TextBoxAfd.Value .Cells(iRow, 2).Value = Me.TextBoxGeb.Value .Cells(iRow, 3).Value = Me.TextBoxVerd.Value .Cells(iRow, 4).Value = Me.TextBoxKmnr.Value .Cells(iRow, 5).Value = Me.TextBoxTafel.Value .Cells(iRow, 6).Value = Me.TextBox220.Value .Cells(iRow, 7).Value = Me.TextBoxS037.Value End With 'clear the data Me.TextBoxAfd.Value = "" Me.TextBoxGeb.Value = "" Me.TextBoxVerd.Value = "" Me.TextBoxKmnr.Value = "" Me.TextBoxTafel.Value = "" Me.TextBox220.Value = "" Me.TextBoxS037.Value = "" Me.TextBoxAfd.SetFocus End Sub Private Sub CommandButton1_Click() Me.Tag = vbOK Me.RedoAction End Sub Private Sub CommandButton2_Click() Me.Tag = vbCancel Me.Hide End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub UserForm_Initialize() Me.TextBoxAfd.Value = "" Me.TextBoxGeb.Value = "" Me.TextBoxVerd.Value = "" Me.TextBoxKmnr.Value = "" Me.TextBoxTafel.Value = "" Me.TextBox220.Value = "" Me.TextBoxS037.Value = "" Me.TextBoxAfd.SetFocus End Sub Private Sub UserForm_QueryClose(Cancel As Integer, _ CloseMode As Integer) If CloseMode = vbFormControlMenu Then Cancel = True MsgBox "Please use the button!" End If End Sub Hope someone can help me out! greets rens |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
help please what am i doing wrong? | Excel Discussion (Misc queries) | |||
What am I doing wrong? | Charts and Charting in Excel | |||
Insert Calculated Field (wrong Qty*Price = wrong Amount) | Excel Discussion (Misc queries) | |||
Am I doing something wrong here? | Excel Programming | |||
Anybody see anything wrong with this | Excel Programming |