Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default where does it go wrong?

Have you set the variable wksBlad1? Is TextBoxAfd not empty?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"minostrada" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default where does it go wrong?

Bob,

I only uses Worksheet1 at this moment. maybe I have to use 2 sheets, one as
the informationbase and the second as the resultpage? TextboxAfd is empty
when you start the form for the first time. When I fill in the complete form,
then the info will still not be used.

"Bob Phillips" wrote:

Have you set the variable wksBlad1? Is TextBoxAfd not empty?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"minostrada" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default where does it go wrong?

Is wksBlad1 some local language equivalent of Worksheet1? As long as this is
so, and that textbox gets populated it looks as though it should work. I
will test it later today?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"minostrada" wrote in message
...
Bob,

I only uses Worksheet1 at this moment. maybe I have to use 2 sheets, one

as
the informationbase and the second as the resultpage? TextboxAfd is empty
when you start the form for the first time. When I fill in the complete

form,
then the info will still not be used.

"Bob Phillips" wrote:

Have you set the variable wksBlad1? Is TextBoxAfd not empty?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"minostrada" wrote in message
...
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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default where does it go wrong?

Yes Bob, it's Dutch for worksheet1. Everytime when I read trough the code, I
can't find a single thing what should stop the form to copy the info...

"Bob Phillips" wrote:

Is wksBlad1 some local language equivalent of Worksheet1? As long as this is
so, and that textbox gets populated it looks as though it should work. I
will test it later today?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"minostrada" wrote in message
...
Bob,

I only uses Worksheet1 at this moment. maybe I have to use 2 sheets, one

as
the informationbase and the second as the resultpage? TextboxAfd is empty
when you start the form for the first time. When I fill in the complete

form,
then the info will still not be used.

"Bob Phillips" wrote:

Have you set the variable wksBlad1? Is TextBoxAfd not empty?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"minostrada" wrote in message
...
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






Reply
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 05:05 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"