VBA BeforeUpdate Message Code with a CountIf

autixgraphix

New member
Local time
Yesterday, 18:27
Joined
Mar 19, 2014
Messages
1
Newbie to this forum and to Access so I apologize up front.

I am trying to write a BeforeUpdate message code in VBA for a Combo Box in a form that would also contain a CountIf function

Below is what I currently have come up with:

Private Sub XField___BeforeUpdate(Cancel As Integer)

MsgBox (Count(Iif([XTable]![XField]="Y",1,0))-48, vbOkOnly

End Sub

Basically XField only has a total of 48 "Y" available and when they select this combo box, I want it to pop up a message that shows how many of that "Y" are available so they recognize that before completing their task.

Obviously at this point its not working and I cant figure it out. Can anyone out there help?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom