i am trying to setup a couple of msgbox routines to check on 2 different items.
ITEM 1
- using the following text boxes on form [Input Data form].
[Uptime] [Downtime]
I am using the following code (in the Downtime_lostfocus event) to determine
if the msgbox should work or not
Dim dblDownTime As Double
Dim dblUpTime As Double
Dim dblTotalTime As Double
dblUpTime = UpTime
dblDownTime = DownTime
dblTotalTime = dblUpTime + dblDownTime
If dblTotalTime > 8 Then
MsgBox "The total hours of uptime and downtime " & Chr(13) & _
" cannot exceed 8 hours.", vbOKOnly + vbCritical
DownTime.SetFocus
End If
currently i can get the msgbox to pop up, but i want the focus to return to
downtime box after user hits the ok button. right now it just moves on to the
next box.
Item 2
- using the following text boxes on form [Input Data form].
[Defect1_Quantity] [Defect2_Quantity] [Defect3_Quantity] [Other]
[txtTotalDefects] - is a sum of the previous 4 textboxes that updates on
each of the previous four text box's lost_focus() event.
[ScrapPercentage] - has the following code as the Data Control Source.
=IIf([totalpartsran]=0,0,(([txttotaldefects]/[totalpartsran])*100))
[txtComments]
I am trying to use the following for getting a message box to pop up to let
the user know they need to fill in the [txtComments] box on the same form,
then send the focus to the [txtComments] box.
If ScrapPercentage > 2 And txtComments = "" Then
MsgBox "You have a Scrap Percentage greater than 2. " & Chr$(13) & _
"Please add a Comment to the Comment box.", vbOKOnly
txtComments.SetFocus
End If
i've tried to use the previous code in the [ScrapPercentage] box's
afterupdate event, and on each of the defect#_quantity boxes lostfocus
events, as well as the add record command button's gotfocus event.
any help with either of these items would be appreciated. thanks.
jkendrick75 - 29 Apr 2005 21:14 GMT
i've been able to figure out item 1. i changed the code to this
Dim dblDownTime As Double
Dim dblUpTime As Double
Dim dblTotalTime As Double
dblUpTime = UpTime
dblDownTime = DownTime
dblTotalTime = dblUpTime + dblDownTime
If dblTotalTime > 8 Then
MsgBox "The total hours of uptime and downtime " & Chr(13) & _
" cannot exceed 8 hours.", vbOKOnly + vbCritical
Cancel = True
DownTime.Undo
End If
and put it in the DownTime_BeforeUpdate(Cancel As Integer) event
i still need help with item 2. thanks
> i am trying to setup a couple of msgbox routines to check on 2 different items.
> ITEM 1
[quoted text clipped - 40 lines]
>
> any help with either of these items would be appreciated. thanks.
DubboPete - 02 May 2005 09:02 GMT
Hi JK,
have you tried this line for item 2...
'calculate ScrapPercentage
If (me.[ScrapPercentage] > 2) And Isnull(me.[txtComments]) Then
MsgBox "You have a Scrap Percentage greater than 2. " & Chr$(13) & _
"Please add a Comment to the Comment box.", vbOKOnly
me.[txtComments].SetFocus
Exit Sub
Else
' move to whatever field is next in line
Me.[txtnextfield].setfocus
End If
Put this code on the GotFocus event of the next field that gets the focus,
once your input fields are completed
DubboPete
> i've been able to figure out item 1. i changed the code to this
> Dim dblDownTime As Double
[quoted text clipped - 64 lines]
>>
>> any help with either of these items would be appreciated. thanks.
jkendrick75 - 03 May 2005 20:53 GMT
thanks, i put it in the lostfocus event for the boxes that i put a quantity
in. this is working for me so, thanks again.
> Hi JK,
>
[quoted text clipped - 84 lines]
> >>
> >> any help with either of these items would be appreciated. thanks.