Link to home
Create AccountLog in
Avatar of bejhan

asked on

SQL Query Not Behaving As Expected

I'm using an SQL Query inside of an access form list but it is not doing what I expected. What I want the query to do is select tblAccountsSent.File, tblAccountsSent.[Amount], and tblAccountsSent.[FileDateTime] where tblAccountsSent.File is not 0 and tblAccountsSent.SIN is equal to a textbox in the form. Then order them by tblAccountsSent.[FileDateTime].

However, when I run this a message box comes up with a text field in it prompting me to enter a parameter value for tblAccountsSent.[FileDateTime]. Why is this happening and how can I fix it?
SELECT tblAccountsSent.File AS [File Number], IIf(tblAccountsSent.[Amount]=0,"Removed",Format(tblAccountsSent.[Amount])) AS [Total $], Format(tblAccountsSent.[FileDateTime],"d-mmm-yyyy h:nn:ss AM/PM") AS [Date]
FROM tblAccountsSent
WHERE (((tblAccountsSent.File)<>0) AND ((tblAccountsSent.SIN)=[Forms]![frmSearchSIN]![txtSIN]))
ORDER BY tblAccountsSent.[FileDateTime];

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
As angellll stated, you might not have a field by that name.  Also, make sure that, even though the query seems to indicate the fields come from a table, make sure it isn't a query that prompts for a piece of data.