Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default User form with VBA

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default User form with VBA

You say values seem to be incorrect, but then you point to a line that tests
whether the TRIM'med contents of a TextBox is the empty string. What exactly
is the problem?

--
Rick (MVP - Excel)


"mrvento" wrote in message
...
Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect.
i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default User form with VBA

hi
what problems are you having? are you receiving any error messages?

Regards
FSt1

"mrvento" wrote:

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default User form with VBA

Yes, error message:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Method or data member not found
---------------------------
OK Help
---------------------------


"FSt1" wrote:

hi
what problems are you having? are you receiving any error messages?

Regards
FSt1

"mrvento" wrote:

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default User form with VBA

hi
did it highlight txt.name? if so the vb couldn't find txt.name in it's
library. check and make sure it is spelled correctly.

Regards
FSt1

"mrvento" wrote:

Yes, error message:
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

Method or data member not found
---------------------------
OK Help
---------------------------


"FSt1" wrote:

hi
what problems are you having? are you receiving any error messages?

Regards
FSt1

"mrvento" wrote:

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default User form with VBA

You should be using "Trim(Me.txtName.Text)" instead of "Trim(Me.txtName.Value)"
(.Value is applicable to Cells, not text boxes)

--
Time is just the thing that keeps everything from happening all at once


"mrvento" wrote:

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User form with VBA

I don't think this will make a difference.

Neptune Dinosaur wrote:

You should be using "Trim(Me.txtName.Text)" instead of "Trim(Me.txtName.Value)"
(.Value is applicable to Cells, not text boxes)

--
Time is just the thing that keeps everything from happening all at once

"mrvento" wrote:

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default User form with VBA

If the name of the text box is spelt correctly, than maybe the problem is in
the rec ogntion of the user form that it lives on (it's hard to see where
else it could be ....). Try spelling it out explicitly instead of using "Me"
(e.g. try "MyForm.txtName.text").

Using "Me" certainly wouldn't work if the form that contains the target
textbox is not the Active one at the time.


--
Time is just the thing that keeps everything from happening all at once


"Dave Peterson" wrote:

I don't think this will make a difference.

Neptune Dinosaur wrote:

You should be using "Trim(Me.txtName.Text)" instead of "Trim(Me.txtName.Value)"
(.Value is applicable to Cells, not text boxes)

--
Time is just the thing that keeps everything from happening all at once

"mrvento" wrote:

Hi All,

I am in need of some help!!!

I created a userform using VBA, however, my value seems to be incorrect. i
tried everything and nothing seems to work.

This is what I have:

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet

Set ws = Worksheets("ECSProductionLog")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a Name
If Trim(Me.txtName.Value) = "" Then <<<this is were my problems is
Me.txtName.SetFocus
MsgBox "Please enter a name"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 9).Value = Me.txtName.Value
ws.Cells(iRow, 1).Value = Me.txtDailyProductionFrontEnd.Value
ws.Cells(iRow, 2).Value = Me.txtDailyProductionBackEnd.Value
ws.Cells(iRow, 3).Value = Me.txtMeeting.Value
ws.Cells(iRow, 4).Value = Me.txtHoliday.Value
ws.Cells(iRow, 5).Value = Me.txtVacation.Value
ws.Cells(iRow, 6).Value = Me.txtPersonal.Value
ws.Cells(iRow, 7).Value = Me.txtSick.Value
ws.Cells(iRow, 8).Value = Me.txtOther.Value


'clear the data
Me.txtName = ""
Me.txtDailyProductionFrontEnd.Value = ""
Me.txtDailyProductionBackEnd.Value = ""
Me.txtMeeting.Value = ""
Me.txtHoliday.Value = ""
Me.txtVacation.Value = ""
Me.txtPersonal.Value = ""
Me.txtSick.Value = ""
Me.txtOther.Value = ""
Me.txtName.SetFocus

End Sub


--

Dave Peterson

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
Date field in user form & Loading a user form on opening workbook Balan Excel Programming 1 May 24th 08 03:40 PM
Call user form from ThisWorkbook; close file if form closed XP Excel Programming 2 July 20th 07 07:04 PM
Automatically add a textbox to a user form based on user requireme Brite Excel Programming 4 April 7th 07 11:37 PM
User form ComboBox Items: Remember user entries? [email protected] Excel Programming 0 March 29th 07 06:41 PM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM


All times are GMT +1. The time now is 10:38 PM.

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

About Us

"It's about Microsoft Excel"