MCTampa
Board Regular
- Joined
- Apr 14, 2016
- Messages
- 97
I have a form with a drop down for Area Code and Month. Both are numbers.
I am trying to populate a text box with the Type which is found on a table called Seasonality.
Here is what the table Seasonality looks like:
Seasonality
Area and Month are both numbers and Type is text.
My code is as follows:
My issue is that it will function with just Area Code or just Month, but it will not function with the combination of both.
Yes, it returns the wrong value, but I do not get a Type Mismatch error when using one or the other. I get the error when using both.
Thanks,
Mike
I am trying to populate a text box with the Type which is found on a table called Seasonality.
Here is what the table Seasonality looks like:
Seasonality
Area | Month | Type |
---|---|---|
330 | 1 | Mid |
330 | 2 | Peak |
330 | 3 | Peak |
330 | 4 | Mid |
330 | 5 | Mid |
330 | 6 | Mid |
330 | 7 | Peak |
330 | 8 | Mid |
330 | 9 | Low |
330 | 10 | Low |
330 | 11 | Low |
330 | 12 | Low |
Area and Month are both numbers and Type is text.
My code is as follows:
VBA Code:
Private Sub Month_AfterUpdate()
Seasonality = DLookup("[Type]", "Seasonality", "[Area]=" & AreaCode.Value And "[Month]=" & Month.Value)
End Sub
My issue is that it will function with just Area Code or just Month, but it will not function with the combination of both.
Yes, it returns the wrong value, but I do not get a Type Mismatch error when using one or the other. I get the error when using both.
Thanks,
Mike