Pop up Message

B

Bob Vance

If tbStartDate3 does not have a date in it can I get a message box to
apprear instead of getting a Error

MsgBox "There is no date entered!"
Thanks for any help.....Bob

Private Sub cmdBSDateR3_Click()
Me.tbStartDate3 = DateAdd("d", -1, Me.tbStartDate3)
tbEndDate3.SetFocus
tbEndDate3_LostFocus
End Sub
 
J

John W. Vinson

If tbStartDate3 does not have a date in it can I get a message box to
apprear instead of getting a Error

MsgBox "There is no date entered!"
Thanks for any help.....Bob

Private Sub cmdBSDateR3_Click()
Me.tbStartDate3 = DateAdd("d", -1, Me.tbStartDate3)
tbEndDate3.SetFocus
tbEndDate3_LostFocus
End Sub

If IsNull(Me!tbStartDate3) Then
MsgBox "There is no date entered!"
Else
<rest of your code>

The line tbEndDate3_LostFocus appears to be an error - what is it supposed to
do?
 
P

Patricia b Vinotti

Bob Vance said:
If tbStartDate3 does not have a date in it can I get a message box to
apprear instead of getting a Error

MsgBox "There is no date entered!"
Thanks for any help.....Bob

Private Sub cmdBSDateR3_Click()
Me.tbStartDate3 = DateAdd("d", -1, Me.tbStartDate3)
tbEndDate3.SetFocus
tbEndDate3_LostFocus
End Sub
 
B

Bob Vance

John I am still getting a Error 13 Type Mismatch
and a yellow line on
Me.tbStartDate2 = DateAdd("d", -1, Me.tbStartDate2)
Thanks for your help.....Bob

Private Sub cmdBSDateR2_Click()
If IsNull(Me!tbStartDate2) Then
MsgBox "There is no date entered!"
Else

Me.tbStartDate2 = DateAdd("d", -1, Me.tbStartDate2)
tbEndDate2.SetFocus
tbEndDate2_LostFocus
End If
End Sub
 
J

John W. Vinson

John I am still getting a Error 13 Type Mismatch
and a yellow line on
Me.tbStartDate2 = DateAdd("d", -1, Me.tbStartDate2)

Try

Me.tbStartDate2 = DateAdd("d", -1, CDate(Me!tbStartDate2))

Might tbStartDate2 be NULL? That would also explain the error. What date do
you want in the control if that is the case?
 
B

Bob Vance

Thanks John, But got the same result :(
There is a startdate and a finishdate that calculates the days between, I
have a control that puts in the date:
---------------------------------------
Private Sub cmd131Row2_Click()
Me!tbStartDate2 = DateSerial(Year(Date), Month(Date), 1)
Me!tbEndDate2 = DateSerial(Year(Date), Month(Date) + 1, 0)
tbEndDate2.SetFocus
tbEndDate2_LostFocus
End Sub
 
J

John W. Vinson

Thanks John, But got the same result :(
There is a startdate and a finishdate that calculates the days between, I
have a control that puts in the date:
---------------------------------------
Private Sub cmd131Row2_Click()
Me!tbStartDate2 = DateSerial(Year(Date), Month(Date), 1)
Me!tbEndDate2 = DateSerial(Year(Date), Month(Date) + 1, 0)
tbEndDate2.SetFocus
tbEndDate2_LostFocus
End Sub
---------------------------------------------------------------
then I have an arrow each side to plus and minus the days if needed, but if
by accident you click the arrow with no date entered you get a Error, but a
msg box would be nicer than the error.......................Thanks
.........Bob

I'm totally perplexed, Bob. Your description appears to have no relationship
to the code you posted. The Click event of cmd131Row2 (a rather confusing name
for a control don't you think??) will - unless there is a control or field
NAMED Date on the form! - put the first and last days of the current month
into two controls on the form; if these controls are not bound to Date/Time
fields in the table they may get an error. The SetFocus line should probably
have a Me! in front of it. I have NO idea what you intend the
tbEndDate2_LostFocus line to do - set focus and then execute that control's
LostFocus event I presume???

There is nothing in the code about an arrow; your arrow button code could and
should check to see if the control is empty:

If IsNull(Me!tbStartDate2) Then
MsgBox("Please enter a date before you increment it", vbOKOnly)
End If

or perhaps instead of the message box fill in some default date such as
today's date.
 
B

Bob Vance

John, It is not showing the message box if my text box is blank, the text
box is Unbound would that make a difference!
Still getting the yellow line error
Thanks Bob
 
J

John W. Vinson

John, It is not showing the message box if my text box is blank, the text
box is Unbound would that make a difference!

Try changing the line

If IsNull(Me!tbStartDate2) Then

to

If Me!tbStartDate2 & "" = "" Then
 
B

Bob Vance

Thanks John came up with this Error catcher, does it look OK!
Private Sub cmdBSDateR1_Click()

On Error GoTo Err_Command291_Click


Me.tbStartDate1 = DateAdd("d", -1, Me.tbStartDate1)
tbEndDate1.SetFocus
tbEndDate1_LostFocus

Exit_Command291_Click:
Exit Sub

Err_Command291_Click:
MsgBox "There is no Date entered!", vbInformation + vbApplicationModal +
vbOKOnly, "Intellisoft"
Resume Exit_Command291_Click
End Sub
 
Top