I have a Form that has 12 Text Boxes each one uses the following code to populate the box:
-----------------Beginning of Code------------------------
Text251 = Format(DateAdd("m", -0, Now()), "mmm"
Text263 = Format(DateAdd("m", -1, Now()), "mmm"
Text262 = Format(DateAdd("m", -2, Now()), "mmm"
Text261 = Format(DateAdd("m", -3, Now()), "mmm"
Text260 = Format(DateAdd("m", -4, Now()), "mmm"
Text259 = Format(DateAdd("m", -5, Now()), "mmm"
Text258 = Format(DateAdd("m", -6, Now()), "mmm"
Text257 = Format(DateAdd("m", -7, Now()), "mmm"
Text256 = Format(DateAdd("m", -8, Now()), "mmm"
Text255 = Format(DateAdd("m", -9, Now()), "mmm"
Text254 = Format(DateAdd("m", -10, Now()), "mmm"
Text253 = Format(DateAdd("m", -11, Now()), "mmm"
-----------------end of Code------------------------
I am then using the following code to call information from a query counts the number of records for that month and to display that number in a unbound text box
-----------------Beginning of Code------------------------
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text251]'"
If Not rst.EOF Then
Text163 = rst!CountOfCountOfTimeText
End If
Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text263]'"
If Not rst.EOF Then
Text162 = rst!CountOfCountOfTimeText
End If
Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text262]'"
If Not rst.EOF Then
Text161 = rst!CountOfCountOfTimeText
End If
-----------------end of Code------------------------
My delima is that when I run the code I get the same information in each one. I have a feeling that the problem lies in the concatenation of my where statement since I can change it to [Expr2]='Dec' and it works fine. But I need the beginning month to float with each new month
Thanks
-----------------Beginning of Code------------------------
Text251 = Format(DateAdd("m", -0, Now()), "mmm"
Text263 = Format(DateAdd("m", -1, Now()), "mmm"
Text262 = Format(DateAdd("m", -2, Now()), "mmm"
Text261 = Format(DateAdd("m", -3, Now()), "mmm"
Text260 = Format(DateAdd("m", -4, Now()), "mmm"
Text259 = Format(DateAdd("m", -5, Now()), "mmm"
Text258 = Format(DateAdd("m", -6, Now()), "mmm"
Text257 = Format(DateAdd("m", -7, Now()), "mmm"
Text256 = Format(DateAdd("m", -8, Now()), "mmm"
Text255 = Format(DateAdd("m", -9, Now()), "mmm"
Text254 = Format(DateAdd("m", -10, Now()), "mmm"
Text253 = Format(DateAdd("m", -11, Now()), "mmm"
-----------------end of Code------------------------
I am then using the following code to call information from a query counts the number of records for that month and to display that number in a unbound text box
-----------------Beginning of Code------------------------
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text251]'"
If Not rst.EOF Then
Text163 = rst!CountOfCountOfTimeText
End If
Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text263]'"
If Not rst.EOF Then
Text162 = rst!CountOfCountOfTimeText
End If
Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text262]'"
If Not rst.EOF Then
Text161 = rst!CountOfCountOfTimeText
End If
-----------------end of Code------------------------
My delima is that when I run the code I get the same information in each one. I have a feeling that the problem lies in the concatenation of my where statement since I can change it to [Expr2]='Dec' and it works fine. But I need the beginning month to float with each new month
Thanks