2012-10-01

Hi All,

Please see my code below (it is a bit large and I am 95% certain that there is an easy way but I am a VBA beginner.

This works but now all I want to do is save the record if the controls aren't empty.

I know access automatically saves when closing but I have restricted the close button as I believe a normal user likes the sense of security clicking SAVE!!

I knew the code to do it before but I don't know how to add it in with this.

CODE

Private Sub Command68_Click()
If IsNull(Me.Week_Number) Then
Cancel = True
MsgBox "You must enter a value for 'Week Number'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo24) Then
Cancel = True
MsgBox "You must enter a value for 'Programme/Project Manager'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo22) Then
Cancel = True
MsgBox "You must enter a value for 'Project Name'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo69) Then
Cancel = True
MsgBox "You must enter a value for 'Project Code'. Please make a valid entry or press ESC to Cancel"
End If

If IsNull(Me.Combo71) Then
Cancel = True
MsgBox "You must enter a value for 'Project Country'. Please make a valid entry or press ESC to Cancel"
End If

If IsNull(Me.Combo33) Then
Cancel = True
MsgBox "You must enter a value for 'Resource Plan'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo35) Then
Cancel = True
MsgBox "You must enter a value for 'Resource Utilisation'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo44) Then
Cancel = True
MsgBox "You must enter a value for 'Budget Remaining'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo52) Then
Cancel = True
MsgBox "You must enter a value for 'Monthly Survey Carried Out by SDM'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo54) Then
Cancel = True
MsgBox "You must enter a value for 'SOW and PO Available'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo56) Then
Cancel = True
MsgBox "You must enter a value for 'Timeline Plan'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo46) Then
Cancel = True
MsgBox "You must enter a value for 'Billing'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo48) Then
Cancel = True
MsgBox "You must enter a value for 'Monthly Survey Report'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo50) Then
Cancel = True
MsgBox "You must enter a value for 'Customer Escalation'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo60) Then
Cancel = True
MsgBox "You must enter a value for 'Roles and Responsibilities'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo66) Then
Cancel = True
MsgBox "You must enter a value for 'Risk and Issue Log Updated'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Combo58) Then
Cancel = True
MsgBox "You must enter a value for 'WBS and Dictionary Up to Date'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.bgm) Then
Cancel = True
MsgBox "You must enter a value for 'Budgeted Gross Margin %'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.pgm) Then
Cancel = True
MsgBox "You must enter a value for 'Projected Gross Margin'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.agm) Then
Cancel = True
MsgBox "You must enter a value for 'Actual Gross Margin'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.tem) Then
Cancel = True
MsgBox "You must enter a value for 'Total Expected Margin'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.ter) Then
Cancel = True
MsgBox "You must enter a value for 'Total Expected Revenue'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.rtd) Then
Cancel = True
MsgBox "You must enter a value for 'Revenue to Date'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.cr) Then
Cancel = True
MsgBox "You must enter a value for 'Change Reqeusts (Total Revenue)'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.pc) Then
Cancel = True
MsgBox "You must enter a value for 'Percentage Complete %'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.CWRExternal) Then
Cancel = True
MsgBox "You must enter a value for 'Customer Weekly Report (External)'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.CWRInternal) Then
Cancel = True
MsgBox "You must enter a value for 'Customer Weekly Report (Internal)'. Please make a valid entry or press ESC to Cancel"
End If
If IsNull(Me.Text73) Then
Cancel = True
MsgBox "You must enter a value for 'Comments'. If no comments please put 'N/A'. Please make a valid entry or press ESC to Cancel"
End If

End Sub

Show more