G
Guest
Hello.
I've been stumbling around the forums and trying a variety of things, but
can't solve this problem. Here's what I'm trying to do:
I have a form control which queries the open quantity for a job. The query
criteria use three other controls on that form to filter the results to a
single record. I want to ensure the user cannot mistype a quantity greater
than the actual quantity open.
I appreciate any assistance!
Dim db As Database
Dim qdf As QueryDef
Dim rs As Recordset
Dim QTY As Integer
Dim total As Integer
Dim PullFIELD As Control
Function QTY_PULL()
Set db = CurrentDb()
Set qdf = db.QueryDefs!PullQtyVB
Set rs = qdf.OpenRecordset(dbOpenDynaset)
rs.MoveFirst
Set PullFIELD = Screen.ActiveControl
QTY = PullFIELD.Value
total = rs.Fields("QuantityOpen")
If (QTY) > (total) Then
MsgBox ("QUANTITY ENTERED CANNOT BE MORE THAN PULL QUANTITY!")
PullFIELD.Value = Null
SendKeys "+{TAB}"
Exit Function
Else
PullFIELD.Value = QTY
End If
End Function
I've been stumbling around the forums and trying a variety of things, but
can't solve this problem. Here's what I'm trying to do:
I have a form control which queries the open quantity for a job. The query
criteria use three other controls on that form to filter the results to a
single record. I want to ensure the user cannot mistype a quantity greater
than the actual quantity open.
I appreciate any assistance!
Dim db As Database
Dim qdf As QueryDef
Dim rs As Recordset
Dim QTY As Integer
Dim total As Integer
Dim PullFIELD As Control
Function QTY_PULL()
Set db = CurrentDb()
Set qdf = db.QueryDefs!PullQtyVB
Set rs = qdf.OpenRecordset(dbOpenDynaset)
rs.MoveFirst
Set PullFIELD = Screen.ActiveControl
QTY = PullFIELD.Value
total = rs.Fields("QuantityOpen")
If (QTY) > (total) Then
MsgBox ("QUANTITY ENTERED CANNOT BE MORE THAN PULL QUANTITY!")
PullFIELD.Value = Null
SendKeys "+{TAB}"
Exit Function
Else
PullFIELD.Value = QTY
End If
End Function