Check multiple controls for Null and notify (1 Viewer)

Zydeceltico

Registered User.
Local time
Today, 11:35
Joined
Dec 5, 2017
Messages
843
Hi All -

Attached is my db, It opens to the form in question.

That form has three combo boxes that cannot be null when one of the buttons in the lower left of the form are clicked.

Currently, if you don't select a Job and then click "Mill Inspection" you'll get a msgbx telling you that you need to make a selection. That is in the On_Click event of that button. The code is:

Code:
Private Sub cmdOpenMillInspection_Click()
  Me.Dirty = False
  If Not IsNull(Me.InspectionEvent_PK) Then
    DoCmd.OpenForm "frmInspectMill", , , , , acDialog, Me.InspectionEvent_PK
    'Me.Requery
  Else
    MsgBox "No Job Chosen. Parent Record Not Saved"
  End If
End Sub

I have two issues:
1) I need the other two combo boxes to be checked for Null also and with a msgbx reminder for both of them if either or both are Null;

2) I wonder if I should put the checking code on the Main form instead of the button because I would have to put it on every button if I go that route.

Thanks for your help!

Tim
 

Attachments

  • TIms QCDB 3-13-19.zip
    250.8 KB · Views: 37

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:35
Joined
Jul 9, 2003
Messages
16,269

Attachments

  • Check multiple controls for Null and notify_ATH.zip
    256.4 KB · Views: 94
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:35
Joined
Jul 9, 2003
Messages
16,269
Download it Again, as I Have made some cosmetic Changes (Removed redundant Code)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:35
Joined
Jul 9, 2003
Messages
16,269
This routine will check every single combo box on your Form. If you don't want it to check them all, then put a "X" in the tag property of the combo boxes that you do want checked, and uncomment the IF Statement and the END IF statement that goes with it:-

Code:
            [COLOR="Red"]'If Ctrl.Tag = "X" Then[/COLOR]

Code:
            [COLOR="red"]'End If[/COLOR]

Code:
           [COLOR="red"] 'If Ctrl.Tag = "X" Then[/COLOR]
                If fCboNullBlankZero(Ctrl) Then
                    MsgBox " YOU need to Enter Data in COMBO BOX >>> " & Ctrl.Name
                    Ctrl.SetFocus
                    Ctrl.Dropdown
                    Exit Function
                End If
           [COLOR="red"] 'End If[/COLOR]
 
Last edited:

Zydeceltico

Registered User.
Local time
Today, 11:35
Joined
Dec 5, 2017
Messages
843
This routine will check every single combo box on your Form.

That is so cool! And I could have been 10 lifetimes trying to figure that out.

Giz - If you're ever in Pittsburgh I owe you big time!

Thank You

Tim
 

Zydeceltico

Registered User.
Local time
Today, 11:35
Joined
Dec 5, 2017
Messages
843
So......having a hiccup.


Copied and pasted code to all of the buttons on frmInspectionEvent and changed the control name references accordingly......


All of the buttons respond as they should On Click except for "Line Stop" and "New Coil Setup."

For some reason those two are not passing the very critical InspectionEvent_FK through to the opening form - - - and I cannot figure out why.

Any ideas?

Thanks a ton!

Tim
 

Attachments

  • QC DB 3-14-19.zip
    241.8 KB · Views: 32

Zydeceltico

Registered User.
Local time
Today, 11:35
Joined
Dec 5, 2017
Messages
843
And soooo.....

I figured it out.


I forgot to put the following code in the On Load event of the two forms:


Code:
  Dim rs As DAO.Recordset
  If Not Trim(Me.OpenArgs & " ") = "" Then
    'See if record exists
    Set rs = Me.Recordset
    'MsgBox Me.OpenArgs
    rs.FindFirst "InspectionEvent_FK = " & CLng(Me.OpenArgs)
    If rs.NoMatch Then  'it does not exist so you need to create it
      DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
      Me.InspectionEvent_FK = Me.OpenArgs
    End If
  End If

You're welcome - to all those who come behind me wondering how the hell any of this works. LOL :)
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:35
Joined
Jul 9, 2003
Messages
16,269
By the way on your form, of those three combo boxes, I think at least two of them had detached labels! Now that's not a detached retina! A detached label is something even worse! Just kidding! I thought you might like to re-attach the labels, I'm not 100% sure everybody knows this of this little trick. I did a little video (Length 52 seconds) on how to do it see here:-

Attach a Label - Nifty Access

If you want to do something nice for me, in appreciation for my help, then the best thing you could do is subscribe to my YouTube channel!
CLICK TO SUBSCRIBE

When I get to 1000 subscribers I get a level up, which means I get access to some extra YouTube features which I would love to have. It will also spur me on to create more of videos demonstrating what you can do with MS Access.

Your Subscription would be most valuable!
Cheers Tony
 

Users who are viewing this thread

Top Bottom