Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default random dates showing up in userform

Hi

I was wondering if someone could help me out a little as I think I am
going to go completely crazy if I spend another minute scanning through
the archives in these groups.

My problem is that I have a user form that I use to view and edit data
on and excel spreadsheet. There are 15 textboxes most of which are
dates and 2 comboboxes that all hold different data. I have the form
set up to view all the fields but I only let 10 of the textboxes and
the two combo boxs be amended as the other five textboxes run formulas
from the data that can be entered. My problem is that when I view the
data in the userform any of the cells that have nothing entered into
them show up in the form with the date 30/12/1899. Does anyone know
why the absence of data in these cells would show up as the given date
when I view the userform???

Any help would be great as I can't seem to find anything like this in
the group posts. I have included the code I have been using on the
userform in question which is probably the problem but I am pretty much
try to learn vba from the net so I hope you can cut me some slack for
any really bad code : )

Here is the code

Private Sub Cmdcancel_p_Click()
Unload Me
Ufmfrontdesk.MultiPage1.Value = 2
Ufmfrontdesk.Show vbModal
End Sub

Private Sub Cmdfind_p_Click()
On Error GoTo errorhandler
Worksheets("primary").Range("a1:a100").Select
Selection.Find(what:=Me.Txtname_p.Text, after:=ActiveCell,
LookIn:=xlValues, _
lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False).Activate
Me.Txtname_p.Value = ActiveCell
Me.Txtref_p.Value = ActiveCell.Offset(0, 1)
Me.Txtfirstday_p.Value = FormatDateTime(ActiveCell.Offset(0, 2),
vbShortDate)
Me.Txtlastday_p.Value = FormatDateTime(ActiveCell.Offset(0, 3),
vbShortDate)
Me.Txtguidancedate_p.Value = FormatDateTime(ActiveCell.Offset(0,
4), vbShortDate)
Me.Txtnotificationdate_p.Value =
FormatDateTime(ActiveCell.Offset(0, 5), vbShortDate)
Me.Txtdepositdue_p.Value = FormatDateTime(ActiveCell.Offset(0, 6),
vbShortDate)
Me.Txtdeposited_p.Value = FormatDateTime(ActiveCell.Offset(0, 7),
vbShortDate)
Me.Txtppldue_p.Value = FormatDateTime(ActiveCell.Offset(0, 8),
vbShortDate)
Me.Txtpplissued_p.Value = FormatDateTime(ActiveCell.Offset(0, 9),
vbShortDate)
Me.Txtreportdue_p.Value = FormatDateTime(ActiveCell.Offset(0, 10),
vbShortDate)
Me.Txtreportissued_p.Value = FormatDateTime(ActiveCell.Offset(0,
11), vbShortDate)
Me.TxtpublishDue_p.Value = FormatDateTime(ActiveCell.Offset(0, 12),
vbShortDate)
Me.Txtpublished_p.Value = FormatDateTime(ActiveCell.Offset(0, 13),
vbShortDate)
Me.Cmbfollowup_p.Value = ActiveCell.Offset(0, 14)
Me.Cmbgrade_p.Value = ActiveCell.Offset(0, 15)
Me.Txtcomments_p.Value = ActiveCell.Offset(0, 16)
Exit Sub
errorhandler:
MsgBox "No Report Found", vbOKOnly, "Report Not Found"
Call UserForm_Initialize
End Sub

Private Sub Cmdsave_p_Click()
ActiveCell.Value = Txtname_p.Value
ActiveCell.Offset(0, 1) = Txtref_p.Value
ActiveCell.Offset(0, 2) = Txtfirstday_p.Value
ActiveCell.Offset(0, 3) = Txtlastday_p.Value
ActiveCell.Offset(0, 5) = Txtnotificationdate_p.Value
ActiveCell.Offset(0, 7) = Txtdeposited_p.Value
ActiveCell.Offset(0, 9) = Txtppldate_p.Value
ActiveCell.Offset(0, 11) = Txtreportissued_p.Value
ActiveCell.Offset(0, 13) = Txtpublished_p.Value
ActiveCell.Offset(0, 14) = Cmbfollowup_p.Value
ActiveCell.Offset(0, 15) = Cmbgrade_p.Value
ActiveCell.Offset(0, 16) = Txtcomments_p.Value
End Sub

Private Sub UserForm_Initialize()
Txtname_p.Text = ""
Txtref_p.Text = ""
Txtfirstday_p.Text = ""
Txtlastday_p.Text = ""
Txtguidancedate_p.Text = ""
Txtnotificationdate_p.Text = ""
Txtdepositdue_p.Text = ""
Txtdeposited_p.Text = ""
Txtppldue_p.Text = ""
Txtpplissued_p.Text = ""
Txtreportdue_p.Text = ""
Txtreportissued_p.Text = ""
TxtpublishDue_p.Text = ""
Txtpublished_p.Text = ""
Cmbfollowup_p.List = Array("", "Yes", "No")
Cmbfollowup_p.ListIndex = 0
Cmbgrade_p.List = Array("", "1", "2", "3", "4")
Cmbgrade_p.ListIndex = 0
Txtcomments_p.Text = ""
End Sub



thanks for looking

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default random dates showing up in userform

If the cell is empty, excel will treat it as 0. And if you do this:

msgbox FormatDateTime(0,vbShortDate)

You'll see December 30, 1899.

Maybe you should check to see if the cell is empty or greater than 0 before you
populate the textbox.



wrote:

Hi

I was wondering if someone could help me out a little as I think I am
going to go completely crazy if I spend another minute scanning through
the archives in these groups.

My problem is that I have a user form that I use to view and edit data
on and excel spreadsheet. There are 15 textboxes most of which are
dates and 2 comboboxes that all hold different data. I have the form
set up to view all the fields but I only let 10 of the textboxes and
the two combo boxs be amended as the other five textboxes run formulas
from the data that can be entered. My problem is that when I view the
data in the userform any of the cells that have nothing entered into
them show up in the form with the date 30/12/1899. Does anyone know
why the absence of data in these cells would show up as the given date
when I view the userform???

Any help would be great as I can't seem to find anything like this in
the group posts. I have included the code I have been using on the
userform in question which is probably the problem but I am pretty much
try to learn vba from the net so I hope you can cut me some slack for
any really bad code : )

Here is the code

Private Sub Cmdcancel_p_Click()
Unload Me
Ufmfrontdesk.MultiPage1.Value = 2
Ufmfrontdesk.Show vbModal
End Sub

Private Sub Cmdfind_p_Click()
On Error GoTo errorhandler
Worksheets("primary").Range("a1:a100").Select
Selection.Find(what:=Me.Txtname_p.Text, after:=ActiveCell,
LookIn:=xlValues, _
lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False).Activate
Me.Txtname_p.Value = ActiveCell
Me.Txtref_p.Value = ActiveCell.Offset(0, 1)
Me.Txtfirstday_p.Value = FormatDateTime(ActiveCell.Offset(0, 2),
vbShortDate)
Me.Txtlastday_p.Value = FormatDateTime(ActiveCell.Offset(0, 3),
vbShortDate)
Me.Txtguidancedate_p.Value = FormatDateTime(ActiveCell.Offset(0,
4), vbShortDate)
Me.Txtnotificationdate_p.Value =
FormatDateTime(ActiveCell.Offset(0, 5), vbShortDate)
Me.Txtdepositdue_p.Value = FormatDateTime(ActiveCell.Offset(0, 6),
vbShortDate)
Me.Txtdeposited_p.Value = FormatDateTime(ActiveCell.Offset(0, 7),
vbShortDate)
Me.Txtppldue_p.Value = FormatDateTime(ActiveCell.Offset(0, 8),
vbShortDate)
Me.Txtpplissued_p.Value = FormatDateTime(ActiveCell.Offset(0, 9),
vbShortDate)
Me.Txtreportdue_p.Value = FormatDateTime(ActiveCell.Offset(0, 10),
vbShortDate)
Me.Txtreportissued_p.Value = FormatDateTime(ActiveCell.Offset(0,
11), vbShortDate)
Me.TxtpublishDue_p.Value = FormatDateTime(ActiveCell.Offset(0, 12),
vbShortDate)
Me.Txtpublished_p.Value = FormatDateTime(ActiveCell.Offset(0, 13),
vbShortDate)
Me.Cmbfollowup_p.Value = ActiveCell.Offset(0, 14)
Me.Cmbgrade_p.Value = ActiveCell.Offset(0, 15)
Me.Txtcomments_p.Value = ActiveCell.Offset(0, 16)
Exit Sub
errorhandler:
MsgBox "No Report Found", vbOKOnly, "Report Not Found"
Call UserForm_Initialize
End Sub

Private Sub Cmdsave_p_Click()
ActiveCell.Value = Txtname_p.Value
ActiveCell.Offset(0, 1) = Txtref_p.Value
ActiveCell.Offset(0, 2) = Txtfirstday_p.Value
ActiveCell.Offset(0, 3) = Txtlastday_p.Value
ActiveCell.Offset(0, 5) = Txtnotificationdate_p.Value
ActiveCell.Offset(0, 7) = Txtdeposited_p.Value
ActiveCell.Offset(0, 9) = Txtppldate_p.Value
ActiveCell.Offset(0, 11) = Txtreportissued_p.Value
ActiveCell.Offset(0, 13) = Txtpublished_p.Value
ActiveCell.Offset(0, 14) = Cmbfollowup_p.Value
ActiveCell.Offset(0, 15) = Cmbgrade_p.Value
ActiveCell.Offset(0, 16) = Txtcomments_p.Value
End Sub

Private Sub UserForm_Initialize()
Txtname_p.Text = ""
Txtref_p.Text = ""
Txtfirstday_p.Text = ""
Txtlastday_p.Text = ""
Txtguidancedate_p.Text = ""
Txtnotificationdate_p.Text = ""
Txtdepositdue_p.Text = ""
Txtdeposited_p.Text = ""
Txtppldue_p.Text = ""
Txtpplissued_p.Text = ""
Txtreportdue_p.Text = ""
Txtreportissued_p.Text = ""
TxtpublishDue_p.Text = ""
Txtpublished_p.Text = ""
Cmbfollowup_p.List = Array("", "Yes", "No")
Cmbfollowup_p.ListIndex = 0
Cmbgrade_p.List = Array("", "1", "2", "3", "4")
Cmbgrade_p.ListIndex = 0
Txtcomments_p.Text = ""
End Sub

thanks for looking


--

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
Stop dates from showing as numbers - when formated as dates JR Excel Discussion (Misc queries) 1 October 29th 08 04:38 PM
How can I generate a list of random dates from dates I specify JJ TUMIA Excel Worksheet Functions 2 August 8th 08 12:23 PM
how do I sort a column of random dates into Consecutive dates Rob Gibson Excel Worksheet Functions 2 June 12th 07 05:10 AM
Random numbers appearing, calculations showing as zero ophelia Excel Programming 6 April 25th 06 02:55 PM
Showing a unique random number w/o duplicates tx12345 Excel Worksheet Functions 4 August 27th 05 02:51 AM


All times are GMT +1. The time now is 08:37 PM.

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"