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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using a >= criteria in query pulling a form field

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
GB
Dear All,

Please help...
I have a query DcUndecidedForXDays.

This query has a field called DaysGone.
The field is as such.
Code:
DaysGone: (Date()-[UNI7LIVE_DCAPPL].[DATEAPVAL])
The criteria are as such:
Code:
>=[Forms]![MainScreen]![SrchCrit]
This gives an error.
ODBC--Call failed
I have tried
Code:
like >=[Forms]![MainScreen]![SrchCrit]
This gives blank results...incorrect.
I have tried this as well:
Code:
Like >="*" & [Forms]![MainScreen]![SrchCrit] & "*"
This also gives blank results!
Please help I am at a loss...[sadeyes]
Thank you!!![bigsmile]

Thank you,

Kind regards

Triacona
 

What value [tt]>=[/tt] what other value?

I think you need to have some values on both sides to compare, 'like' is an operator, reserved word.

Have fun.

---- Andy
 
Your first criteria should work. Can you confirm DATEAPVAL is a date/time field?

Can you provide the entire SQL?

Is DATEAPVAL ever null or empty?

Is the form open with a number in the control?

Duane
Hook'D on Access
MS Access MVP
 
Dear Duane,

Thank you for your reply[smile]
DATEAPVAL is a date/time field...
SQL is as follows:
Code:
SELECT UNI7LIVE_DCAPPL.OFFCODE, (Date()-[UNI7LIVE_DCAPPL].[DATEAPVAL]) AS DaysGone, UNI7LIVE_DCAPPL.DATEAPVAL, UNI7LIVE_DCAPPL.DATEDECISN, UNI7LIVE_DCAPPL.REFVAL, UNI7LIVE_DCAPPL.PROPOSAL, UNI7LIVE_DCAPPL.ADDRESS, UNI7LIVE_DCAPPL.DATE8WEEK, UNI7LIVE_DCAPPL.DATEAPRECV, UNI7LIVE_DCAPPL.DCSTAT, UNI7LIVE_DCAPPL.DCAPPTYP, UNI7LIVE_DCAPPL.DECTYPE, UNI7LIVE_DCAPPL.DATEDECISS
FROM UNI7LIVE_DCAPPL
WHERE (((UNI7LIVE_DCAPPL.OFFCODE) Like "*" & [Forms]![MainScreen].[CmbOff] & "*") AND (((Date()-[UNI7LIVE_DCAPPL].[DATEAPVAL]))>=[Forms]![MainScreen]![SrchCrit]) AND ((UNI7LIVE_DCAPPL.DATEAPVAL) Is Not Null) AND ((UNI7LIVE_DCAPPL.DCSTAT) Not In ("NFA","PD","WDN","PPREQ","PDREM","PREAPP","COMP","PDE","CLO")) AND ((UNI7LIVE_DCAPPL.DATEDECISS) Is Null));
I have added a criteria in DATEAPVAL which is:
IS NOT NULL

Yes the form is open with a number in the text box SrchCrit.

Thank you for all your help[bigsmile][2thumbsup]

Thank you,

Kind regards

Triacona
 
I would try hard-code a numeric value in place of the reference to [Forms]![MainScreen]![SrchCrit]. If that works, you may need to set the data type of the form control in the query parameters.

Duane
Hook'D on Access
MS Access MVP
 
DEar Duane,

Thank you for all your help...
I have tried using the criteria in DaysGone:
Code:
>50
This gives me the error:
ODBC--Call Failed
Is this what you meant by hard coding?
How do I set the data type of the form control in the query parameters?

Thanks again[smile]


Thank you,

Kind regards

Triacona
 
Yes, that is what I meant by hard-coding. It appears there is something else wrong with your query. I would try remove all calculations and criteria to see if it works. Then add one calculation or criteria back and try. Keep doing this.

Duane
Hook'D on Access
MS Access MVP
 
Dear Duane,

I have removed calculations - this has worked.
I also found out that the Access Time and Date format differs from this one.
DATEAPVAL is from an oracle database, and has different formating.

How do I change DATEAPVAL formating to one of accesses?

Any help would be greatly appreciated[thumbsup]
Thank you!![smile]

Thank you,

Kind regards

Triacona
 
Dear Duane,

It is formatted 24-Aug-11.

I have tried DateValid:format([DATEAPVAL],"dd/mm/yyyy")
This is the access standard format.
I run this and it appears as such.

I then try
In another query using the query in which I formated DATEAPVAL.
And then created a field DaysGone:(Date()-DateValid)
I run this and the DaysGone field has #error repeated per record.

I have also tried DateAdd().
This has not worked, field DaysGone has #error in it.

Please help I am really banging my head on this one![banghead]
Thank you for all your help![bigsmile]



Thank you,

Kind regards

Triacona
 
Dear Duane,

I will try that thanks [2thumbsup]

Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top