Skip Bisconer
Who Me?
- Local time
- Today, 03:18
- Joined
- Jan 22, 2008
- Messages
- 285
I want to make a function similar to this one provided to me from PBaldy and I don't know how to make it work for me. Originally when working with Paul I had queries built for each month of the year and this would run what ever query that matched the month the process was occuring in. I am trying to do this with one query instead of 12 as I would have to make 12 queries for every warehouse and that would be cumbersome. I now have one query for each warehouse with 12 fields named by the month. I would like this function to populate a textbox on a form when it loads using the month function to pick a query.field.
This is a rotating 8 months average of units sold and a whole bunch of calculations occur to the inventory fields using this field as part of the calcluation. As an example if the buy is reviewing inventory items during January the eight month average would be units sold May-Dec of last year, and of course for Febuary those field would advance one month Jun-Jan of this year etc.
Another issue is that there aren't sales for every item in the Inventory master file so some of those fields would remain 0, so the function would have to loop through the entire record.
First is this possible and second, if so how do I structure the statement
StrQuery = "What query.field"?
Function MonthlyAverage()
Dim strQuery As String
Select Case Month(Date)
Case 1
strQuery = "QueryToUseForJanuary"
Case 2
strQuery = "QueryToUseForFebruary"
End Select
Set rs = db.OpenRecordset(strQuery, , dbOpenDynamic)
End Function
This is a rotating 8 months average of units sold and a whole bunch of calculations occur to the inventory fields using this field as part of the calcluation. As an example if the buy is reviewing inventory items during January the eight month average would be units sold May-Dec of last year, and of course for Febuary those field would advance one month Jun-Jan of this year etc.
Another issue is that there aren't sales for every item in the Inventory master file so some of those fields would remain 0, so the function would have to loop through the entire record.
First is this possible and second, if so how do I structure the statement
StrQuery = "What query.field"?
Function MonthlyAverage()
Dim strQuery As String
Select Case Month(Date)
Case 1
strQuery = "QueryToUseForJanuary"
Case 2
strQuery = "QueryToUseForFebruary"
End Select
Set rs = db.OpenRecordset(strQuery, , dbOpenDynamic)
End Function
Last edited: