What's the problem here, the code looks fine to me?
[/QUOTE]
Hi Norie,
The userform is still letting me place an amount within the txt.Amt.Value box after selecting Indirect. I'm trying to get it so when a user chooses Indirect and then also attempts to place an amount within the txt.Amt.Value text box they are given an error message. I can see I need to add a msgbox within the code to let them know they have entered an amount after choosing Indirect, but right now nothing is happening. Of course, I'm trying to get past the date validation issue nathansav is currently helping me with.
I commented out the date validation portion and attempted to run it to see if the direct/indirect validation was working, nothing is happening after I run it. I get no error, msgbox, or data submittion.
[code]
Private Sub cmdAdd_Click()
Dim lRow As Long
Dim lPart As Long
Dim WS As Worksheet
Set WS = Worksheets("DetailOverShort")
'find first empty row in database
lRow = WS.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
ldate = Me.txtDate.Value
'check for a date
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter a Date"
'ElseIf IsDate(Me.txtDate.Value) <> "mm/dd/yyyy" Then
'Me.txtDate.SetFocus
' MsgBox "Please enter date in correct format"
'Else
'Me.txtDate.Value = ldate
End If
Exit Sub
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With WS
.Unprotect Password:="password"
If MsgBox("Is all data correct?", vbYesNo) = vbNo Then
.Cells(lRow, 2).Value = Me.txtDate.Value
.Cells(lRow, 3).Value = Me.cboDirectIndirect.Value
.Cells(lRow, 4).Value = Me.txtPERNR.Value
.Cells(lRow, 5).Value = Me.txtName.Value
.Cells(lRow, 6).Value = Me.cboLocation.Value
.Cells(lRow, 10).Value = Me.txtAmt.Value
.Cells(lRow, 12).Value = Me.txtCorrection.Value
.Cells(lRow, 14).Value = Me.txtComments.Value
.Cells(lRow, 15).Value = Me.txtKioskNo.Value
.Cells(lRow, 16).Value = Me.txtKioskITDate.Value
.Cells(lRow, 17).Value = Me.txtKioskClosedDate.Value
.Cells(lRow, 18).Value = Me.txtKioskResolution.Value
' .Protect Password:="password"
End If
If cboDirectIndirect.Value = "Indirect" Then
txtAmt.Enabled = False
MsgBox ("You cannot enter a dollar amount when Discrepancy Type is set to Indirect!")
Else
txtAmt.Enabled = True
End If
Exit Sub
End With
'clear the data
Me.txtDate.Value = Format(Date, "Medium Date")
Me.cboDirectIndirect.Value = ""
Me.txtPERNR.Value = ""
Me.txtName.Value = ""
Me.cboLocation.Value = ""
Me.txtAmt.Value = ""
Me.txtCorrection.Value = ""
Me.txtComments.Value = ""
Me.txtKioskNo.Value = ""
Me.txtKioskITDate.Value = ""
Me.txtKioskClosedDate.Value = ""
Me.txtKioskResolution.Value = ""
End Sub
[/code
Bookmarks