Re: Unbound Form making an ODBC call to a DB2 database?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Mr B wrote:
Hi all, I would really appreciate any feedback on this problem as it
has had me stumped for a long time now! I am using Access 97 as a
front-end to a DB2 database and i'm trying to create a query which
will return results from the DB2 database between certain date
values. When the date values are hard-coded, (Between #01/04/06# And
#01/05/06#) for example, this query runs fine and returns the
results. However the snag is, I want the user to be able to enter
these two date values as query criteria in an unbound form. They
enter the dates into a text box, run the query via a macro, and then
the make-table query puts the results in a table.

Between [forms]![qryFind]![tbDateBegin] And
[forms]![qryFind]![tbDateEnd]

This returns with an error message which says that the ODBC call
failed. I have tried using date variables in the forms code,
(dtDateBegin = CDate(tbDateBegin)) but the query returns 0 rows
everytime. I have also tried changing the format of the date using
the date variable.

Format%([forms]![qryFind]![dtDateBegin], "mm-dd-yyyy")

As I was told the IBM DB2 prefered dealing with dates in the format.

Does anyone have any ideas? Is there something basic I have not
done?? I am not an experienced Access Develeper, a few leads I have
had, I dont know what relevance is the use of a pass-through query??
Also would creating a hard-coded query to return all the results in
the expected range first, and then running look-up query on this
table of results work??

Sorry for being so long-winded!! Any feedback much appreciated

Thanks
Daniel

Is this a pass-through query or a query against a linked table? Is it really a
"Date" field in the DB2 database or is it a Timestamp (date and time combined)?

I often find with Timestamps in UDB400 (close relative to DB2) that problems
occur when the underlying data contains fractions of seconds (which Access
doesn't understand). In those cases I have to wrap the field in CDate() which
isn;t great for efficiency, butsolves the problems.

Try...

WHERE CDate(TimeStampField) BETWEEN CDate([forms]![qryFind]![tbDateBegin]) AND
CDate([forms]![qryFind]![tbDateEnd])

If you explicitly declare the form references in the query's parameter box and
specify them as DateTime types you might be able to eliminate the CDate()
functions around the form references.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


.



Relevant Pages

  • Re: Convert Numeric field to Date
    ... I've seen similar questions to this but need some help/clarification. ... I have Access 2003 with linked tables to a DB2 database. ... actual ship date in mm/dd/yyyy format on one query. ... On another query I am trying to summarize item shipments by month. ...
    (microsoft.public.access.queries)
  • Timeout
    ... This DB2 database can get very big and depending on a query ... I am believing it to be a timeout. ... timeout setting but can only max it out 300 seconds and I still get the ODBC ...
    (microsoft.public.access.queries)
  • Re: Pass Through Query / Make Table
    ... Jim Thomlinson wrote: ... I am executing against a DB2 database using Access 2002. ... My pass through query works just fine so long as I don't make it into a make table... ...
    (microsoft.public.access.queries)
  • How do i setup GetDefaultConnect for DB2?
    ... I'm trying to query a DB2 database. ... CRecordset class to a DB2 table Visual Studio closes. ...
    (microsoft.public.vc.mfc)
  • Re: Date criteria
    ... Thanks for the information about CDate. ... evaluate as a date (DateAdd led to a Type Mismatch error message). ... Armed with that information I constructed a small query in which I ... >> month from the current date when applied to a DateSerial expression. ...
    (microsoft.public.access.queries)