[AccessD] custom sorts/groups in a report

Susan Harkins ssharkins at bellsouth.net
Tue Apr 20 15:48:39 CDT 2004


If the expression's in the query and you open the report without specifying
the value in the form, how would you prevent an error in the form? I suppose
I could just handle it and remind the user to open the form and choose the
first day of the week. 

Right now, I've set the report to default to a value and since the
expression's in the report, it works whether you start from the form or just
open the report. You can't specify the grouping value when you open the
report that way, but at least there's no error -- which is a nice
alternative especially if the first day of the week seldom changes. That way
the user's not forced to go through the form every time. 

I realize I sound really picky -- but these are the sort of nitpicky
problems I get from readers. These solutions have to be as universal as
possible or I get email. :) "It won't work if...." even when I've told them
clearly in the article that it won't work if... but somehow it's still the
article's shortcoming. It's always best if I can head them off. 

Which reminds me -- can someone explain the vbUseSystem constant? There's
almost nothing about it on msdn. It's a system default, but there's not much
about it. Well, the serious search-challenged was unable to find anything on
it besides a vague reference -- no real explanation of the consequences.

Susan H. 

Hi Susan

In the query you can pick the value from the form as an expression:

  Select
    ...,
    [Forms].[frmSomeForm].[txtTextbox] As FirstDayOfWeek
  From
    ...

Is is recommendable also to specify this as a parameter to avoid type
mismatch errors, indeed if the textbox is unbound:

  Parameters [Forms].[frmSomeForm].[txtTextbox] Byte;

I don't know what your module does, but basically the date of the first day
of the week of datDate can be found from this formula:

  DateWeekFirst =
    DateAdd("d", vbSunday - WeekDay(datDate, FirstDayOfWeek), datDate)

You would need to replace vbSunday with the actual value (1 for A97).
    
End Function

/gustav


> Let me rephrase that -- if I have to have a module, I don't think I 
> really care what gets passed where -- my hope was to eliminate the 
> module and do all the calculating in the query or the report and I 
> thought I might be able to bypass the module using the openargs 
> argument. Replacing the module I have for one that passes the value to 
> a query really doesn't resolve the issue I had.

> Susan H. 

> That's what I'd like to do -- and may do yet  by passing the 
> firstdayofweek value from the form to the query instead of the report. 
> Truth is, I don't know how -- I can't remember ever passing a value to 
> a query before and a parameter query is out.

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list