TomJamieson
Registered User.
- Local time
- Today, 14:09
- Joined
- Jun 8, 2006
- Messages
- 50
I'm not sure if I'm being really stupid here or not, but I'm rather stuck. I have a report that is created from a query. One of the fields is "Quantity" which is a number between 1 and 500,000. I have a custom label on the form which I want to display a certain number depending on the Quantity. So the user types in the ID of a record, the report opens showing details of that record, and the label automatically works out what number it should display depending on the Quantity.
I just can't figure out how to reference the Quantity field from my vba module. Here's my code:
Private Sub Report_Open(Cancel As Integer, qty As Integer)
qty = DLookup("[Quantity]", qryQCSheet)
If qty >= 2 And qty <= 8 Then
lblNoIns.Caption = 2
Exit Sub
End If
If qty >= 9 And qty <= 15 Then
lblNoIns.Caption = 3
Exit Sub
End If
If qty >= 16 And qty <= 25 Then
lblNoIns.Caption = 5
Exit Sub
End If
If qty >= 26 And qty <= 50 Then
lblNoIns.Caption = 8
Exit Sub
End If
End Sub
It's just the defining of the qty variable that it gets stuck on, the rest is all fine. Any ideas?
Many thanks.
I just can't figure out how to reference the Quantity field from my vba module. Here's my code:
Private Sub Report_Open(Cancel As Integer, qty As Integer)
qty = DLookup("[Quantity]", qryQCSheet)
If qty >= 2 And qty <= 8 Then
lblNoIns.Caption = 2
Exit Sub
End If
If qty >= 9 And qty <= 15 Then
lblNoIns.Caption = 3
Exit Sub
End If
If qty >= 16 And qty <= 25 Then
lblNoIns.Caption = 5
Exit Sub
End If
If qty >= 26 And qty <= 50 Then
lblNoIns.Caption = 8
Exit Sub
End If
End Sub
It's just the defining of the qty variable that it gets stuck on, the rest is all fine. Any ideas?
Many thanks.