Message box prompt

jodilees

Registered User.
Local time
Today, 09:55
Joined
Nov 17, 2002
Messages
40
Hi everyone

I am not very good with code and any help would be greatly appreciated.

I am trying to achieve the following.

I have a series of fields in a form. Each has figures in them. I have summed the fields into one field. When all of the fields are reduced to 0 I want it to look at the total field and tell me that this field = 0 and to prompt me with a message box that there are no hours left in this job. I then check the ok button and the completed check box on the main form to demonstrate that the job is complete. This is the code I have entered, but it is not working. It is not returning any error messages, but is not doing what I want it to do either.

Private Sub Total_Hours_Change()
If [Total Hours] < 0.0001 Then
MsgBox "There are no hours left to complete"
End Sub

Further to this, in an ideal world I would like the message box that prompts me about the jobs completion to have a yes to confirm and a no to deny completion button. If the yes button is clicked then the completed check box is automatically checked on the main form. If no is clicked then the form is left as is.

Any thoughts would be really appreciated. It is probably a simple task, but as I said I am hopeless with code.

Kind Regards

Jodi
 
jodilees said:
Private Sub Total_Hours_Change()
If [Total Hours] < 0.0001 Then
MsgBox "There are no hours left to complete"
End Sub

You need to put End If (not End Sub) and refer to the form with the Me. expression.
Also I'm not sure the OnChange is the place to put it but try it anyway.

Private Sub Total_Hours_Change()
If Me.Total Hours < 0.0001 Then
MsgBox "There are no hours left to complete"
End If

Col
 
Hi,
I think your code would look like this, in the forms current event.
Code:
Private Sub Form_Current()

 If Me.Total_Hours < 0.0001 Then
      If MsgBox("There are no hours left to complete, Do you want to complete this job?", vbYesNo, "Complete Job?") = vbYes Then
           Me.YourCheckBox = True
      Else
      End If
 End If

End Sub
HTH
 
Last edited:
Hi thanks for your help.

I have cut ant pasted both codes in, but it is still not prompting with the message box. It is not returning any errors either. Any further suggestions?

Kind Regards

Jodi
 
I assume TotalHours is a calculated field in which case the posted solutions will not work. You'll have to use vba to calculate the TotalHours and then use the MsgBox function
 
Rich said:
I assume TotalHours is a calculated field in which case the posted solutions will not work. You'll have to use vba to calculate the TotalHours and then use the MsgBox function

Ok so how do I go about this?

Regards

Jodi
 
Code Not Working Help Me Please

Hi all

Please see conversation for the rest of the thread. Is there anyone out there that can help me further with this?

Regards

Jodi
 

Users who are viewing this thread

Back
Top Bottom