LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help please what am i doing wrong? Nevyn Excel Discussion (Misc queries) 1 February 9th 10 10:50 PM
What am I doing wrong? tjbo Charts and Charting in Excel 3 October 10th 08 02:08 PM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
Am I doing something wrong here? TyeJae[_21_] Excel Programming 2 June 29th 04 12:56 AM
Anybody see anything wrong with this Dthmtlgod Excel Programming 1 April 20th 04 03:16 PM


All times are GMT +1. The time now is 04:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"