That gets tricky. Textboxes have a feature called Conditional Formatting that can disable a textbox if a condition is met but Image controls don't have that. Image control doesn't even have an Enabled property to be manipulated.
Try code for each cookie image Click.
Code:
Private Sub Image0_Click()
If Me.Samoas + 1 > Me.Text26 Then
DoCmd.Beep
MsgBox "No boxes available."
Me.Image0.Visible = False
Else
Me.Samoas = Me.Samoas + 1
End If
End Sub
Probably also should have code in form Load event that makes image visible/not visible.
Private Sub Form_Load()
Me.Image0.Visible = Not Me.Text26 = 0
Me.Image14.Visible = Not Me.Text28 = 0
Me.Image16.Visible = Not Me.Text31 = 0
Me.Image19.Visible = Not Me.Text33 = 0
Me.Image21.Visible = Not Me.Text38 = 0
Me.Image24.Visible = Not Me.Text55 = 0
End Sub
The images could be a 'grey' image. If you use 'grey' images, set their Visible property on the Property Sheet to no and remove the Not qualifier from the code expression.
Code is much easier to read if controls have meaningful names, like: imgSamoas, tbxSamoasBal.