Cirrostratus
Registered User.
- Local time
- Today, 12:18
- Joined
- May 16, 2013
- Messages
- 29
I have a form where a user enters data. One of the things the user enters is a "lot size". I need this lot size field to be checked against a query in the database to determine if the quantity is acceptable or not.
The order number in this query is in certain cases missing a leading zero, so I need to truncate this from the user entered form field.
Finally I want the user to be notified if they are trying to exceed the lot size in the query.
My code is as follows:
I cant get this code to work :banghead:. Can you guys help me out and point out what is wrong with it? All the help is greatly appreciated!!
The order number in this query is in certain cases missing a leading zero, so I need to truncate this from the user entered form field.
Finally I want the user to be notified if they are trying to exceed the lot size in the query.
My code is as follows:
Code:
Public Function RemoveFirstChar(RemFstChar As String) As String
Dim TempString As String
TempString = RemFstChar
If Left(RemFstChar, 1) = "0" Then
If Len(RemFstChar) > 1 Then
TempString = Right(RemFstChar, Len(RemFstChar) - 1)
End If
End If
RemoveFirstChar = TempString
End Function
Private Sub Lot_Size_AfterUpdate()
Dim strWhere As String
strWhere = "([Order_No]=""& RemoveFirstChar(Forms!frmProdStartEntry!Order_No) & "") AND ([Release_No]=""& Forms!frmProdStartEntry!Release_No &"") AND ([Sequence_No]=""& Forms!frmProdStartEntry!Sequence_No &"")"
Buildable = DLookup("[UnitsOpen]", "SQ_ProdUnitsBuildable", strWhere)
If Forms!frmProdStartEntry!Lot_Size > Buildable Then
MsgBox "You can only build " & Buildable & "pcs, please revise qty!", vbInformation, ""
Cancel = True
Me.Lot_Size.SetFocus
Exit Sub
End If
btnStart.SetFocus
End Sub
I cant get this code to work :banghead:. Can you guys help me out and point out what is wrong with it? All the help is greatly appreciated!!