Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My Text Boxes are pulling the wrong data 2

Status
Not open for further replies.

burgerman

Technical User
Sep 21, 2002
31
0
0
US
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

 
this is wrong

Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE '[Expr2]='& '[Forms]![Active Employee Information]![text251]'")

try this

Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE [Expr2]=" & [Forms]![Active Employee Information]![text251])

you have a problem with you single quotes and double quotes
placing
 
Now I get a too few parameters error message when I know there is a matching record in the query. Any Ideas?
 
actually it should read:

Set rst = dbs.OpenRecordset("SELECT * FROM [Month12] WHERE [Expr2]='" & [Forms]![Active Employee Information]![text251] & "'")

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
That was it thanks a million....I burned alot of midnight oil trying to figure that one out.
 
Chrissie deserves a star too...she was almost there....and pointed me and you in the right direction. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top