I have searched the forums and tried several suggestions already posted to try to solve my issue, but have been unsuccessful. What I would like to do is require a subform to have an entry.
My main form (frmInfantFeedingGuide) has a subform (sbfrmIFGLiquids). The subform has one control (Liquids). I used this setup to allow users to enter multiple liquids (milk, water, soda, etc.) for each Infant Feeding Guide. There are also options for none and no response. I would like to make sure that at least one of these item has been selected.
I tried using the IsNull function on the BeforeUpdate event of the subform. But I am able to tab into the subform and back out again without triggering my message box.
If IsNull(Liquids) Then
Cancel = True
Me.Liquids.SetFocus
MsgBox "Liquids is blank. Please make an entry", vbOKOnly
End If
I am wondering if the problem (or at least part of it) is that no entry at all has been made yet? I did try replacing the IsNull function with the IsEmpty function, but couldn't make that work either.
Am I on the wrong path completely? Can I do this with the way my forms are set up? Would using a multi-select listbox make checking for nulls easier (given that I have a very basic level understanding of VBA and am not 100% sure how to create a multi-select listbox although I have seen instructions)? Any suggestions would be appreciated!
Thank you
Kristen
My main form (frmInfantFeedingGuide) has a subform (sbfrmIFGLiquids). The subform has one control (Liquids). I used this setup to allow users to enter multiple liquids (milk, water, soda, etc.) for each Infant Feeding Guide. There are also options for none and no response. I would like to make sure that at least one of these item has been selected.
I tried using the IsNull function on the BeforeUpdate event of the subform. But I am able to tab into the subform and back out again without triggering my message box.
If IsNull(Liquids) Then
Cancel = True
Me.Liquids.SetFocus
MsgBox "Liquids is blank. Please make an entry", vbOKOnly
End If
I am wondering if the problem (or at least part of it) is that no entry at all has been made yet? I did try replacing the IsNull function with the IsEmpty function, but couldn't make that work either.
Am I on the wrong path completely? Can I do this with the way my forms are set up? Would using a multi-select listbox make checking for nulls easier (given that I have a very basic level understanding of VBA and am not 100% sure how to create a multi-select listbox although I have seen instructions)? Any suggestions would be appreciated!
Thank you
Kristen