Validating

sweensterpng

New member
Local time
Today, 18:25
Joined
May 2, 2006
Messages
7
I have a form that creates quotes for my company by inputting inventory items in a continuous subform. I need to be able to check and see if the item already exists in the inventory or if it is a new one that has been manually entered, and have this toggle a bound yes/no field that I will use to control whether or not some fields on the form are locked. Here is the code I have been using, but it doesn't seem to work at all.

Private Sub Combo14_AfterUpdate()
Dim itemcheck As Integer
itemcheck = DCount("[Item]", "tbItems", "[Item] = " & Chr(34) & Me![Item] & Chr(34))
If itemcheck = "0" Then
Me![Locked] = False
Else
Me![Locked] = True
End If
End Sub

I would appreciate anyone's feedback on this.
 
Slightly better code... maybe

I made some changes, so now the code looks like this:

Code:
Private Sub Combo14_AfterUpdate()
Dim ininventory As Boolean
ininventory = IIf(IsNull(DCount("[Item]", "tbItems", "[Item] = " & Chr(34) & [Item] & Chr(34))), True, False)
Me![Locked] = ininventory
End Sub

However, it still isn't working. Shoot.
 
Never mind

I figured it out. I had some VBA code triggered by another object that would change the text of the text box that was supposed to toggle the yes/no field. I just needed to make sure the code was in the after update events for both objects, because I realized that even though the text was changing, it wasn't triggering the after update event. I'm glad this is over, because I was getting unhealthily obsessed with this problem.
 

Users who are viewing this thread

Back
Top Bottom