Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |