Thank you for taking your time to investigate my issue.
I’m having an issue with my user form code after it runs. The first time it runs everything is good however at the end of my code it put default values back in the form for the next entry.
All of the defaults work but the =today() does not. See the below code at very bottom.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><o
> </o
>
<o
>This is what the user form shows now =today()
Instead of the correct 11/9/2011
</o
><o
></o
>
Can someone please point me in the right direction to correct this issue.
<o
> </o
>
The original defaults are set in userForm_Initialze .
<o
> </o
>
<o
> </o
>
<o
> </o
>
<o
> </o
>
<o
> </o
>
I’m having an issue with my user form code after it runs. The first time it runs everything is good however at the end of my code it put default values back in the form for the next entry.
All of the defaults work but the =today() does not. See the below code at very bottom.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com




<o

Instead of the correct 11/9/2011
</o



Can someone please point me in the right direction to correct this issue.
<o


The original defaults are set in userForm_Initialze .
<o


Code:
Private Sub UserForm_Initialize()
sdate.Value = Format(Date, "mm/dd/yyyy")
hours.Value = 4
part.Value = 2
'make.RowSource = "make1"
End Sub


<o


<o


<o


Code:
Private Sub CommandButton1_Click()
Dim rNextCl As Range
Set rNextCl = Worksheets("Main").Cells(Rows.Count, 2).End(xlUp).Offset(2, 0)
Worksheets("Main").Activate
rNextCl.Select
<o:p> </o:p>
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Main")
<o:p> </o:p>
'ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.Unprotect
<o:p> </o:p>
'find first empty row in database
iRow = ws.Cells(Rows.Count, 2) _
.End(xlUp).Offset(1, 0).Row
<o:p> </o:p>
<o:p> </o:p>
If Me.lname = "" Or Me.fname = "" Or Me.year = "" Or Me.make = "" Or Me.model = "" Or Me.wo = "" _
Or Me.sdate = "" Or Me.part = "" Or Me.hours = "" Then
MsgBox ("All Feilds Must be Completed")
<o:p> </o:p>
Exit Sub
End If
<o:p> </o:p>
With ws
.Cells(iRow, 2).Value = Me.lname.Value
.Cells(iRow, 3).Value = Me.fname.Value
.Cells(iRow, 5).Value = Me.year.Value
.Cells(iRow, 6).Value = Me.make.Value
.Cells(iRow, 7).Value = Me.model.Value
.Cells(iRow, 8).Value = Me.wo.Value
.Cells(iRow, 9).Value = Me.sdate.Value
.Cells(iRow, 10).Value = Me.part.Value
.Cells(iRow, 11).Value = Me.hours.Value
<o:p> </o:p>
With .Cells(iRow, 1).Resize(1, 7).Borders
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
<o:p> </o:p>
'Add one to column "A" for the line number
'ws.Cells(iRow, 1).Value = ws.Cells(iRow - 1, 1).Value + 1
<o:p></o:p>
<o:p></o:p>
<o:p> </o:p>
'clear the data and set new defaults
Me.lname.Value = ""
<o:p> </o:p>
Me.fname.Value = ""
<o:p> </o:p>
Me.year.Value = ""
<o:p> </o:p>
Me.make.Value = ""
<o:p> </o:p>
Me.model.Value = ""
<o:p> </o:p>
Me.wo.Value = ""
<o:p> </o:p>
[COLOR=red][B]Me.sdate.Value = "=today()"<o:p></o:p>[/B][/COLOR]
<o:p> </o:p>
Me.part.Value = "2"
<o:p> </o:p>
Me.hours.Value = "4"
<o:p> </o:p>
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'ActiveSheet.Unprotect
End With
End Sub