Acess Form & subForms

T

train.fan#007

Hi, I hope someone can help me.
I have one main form, with four, at least, other forms
within.
The problem is:
I wish to pre-select one form to suit the day of the week.

Explanation:
I have 8 queries based on availability.
I now wish to select, based on which ever day of the week, the correct
query for the particular day.

If anyone can advise me on how to select the
desired query i would be very grateful.

Thanks in advance

Exilescot
 
B

Brendan Reynolds

train.fan#007 said:
Hi, I hope someone can help me.
I have one main form, with four, at least, other forms
within.
The problem is:
I wish to pre-select one form to suit the day of the week.

Explanation:
I have 8 queries based on availability.
I now wish to select, based on which ever day of the week, the correct
query for the particular day.

If anyone can advise me on how to select the
desired query i would be very grateful.

Thanks in advance

Exilescot


I'm not quite sure what it is that you want to do with the query. It is not
clear to me just what you mean by 'select' in this context. I'm going to
take a guess that possibly you want to assign the name of a query to the
record source property of a form? In that case, the code might look
something like so ...

Select Case WeekdayName(Weekday(Date, vbUseSystemDayOfWeek), False,
vbUseSystemDayOfWeek)
Case "Monday"
Me.sfrSomeSubFormControl.Form.RecordSource = "qryQueryForMonday"
Case "Tuesday"
Me.sfrSomeSubFormControl.Form.RecordSource = qryQueryForTuesday"
'etc
End Select

It's difficult to be sure without more information, but it sounds quite
probable that the goal could be achieved with a single parameter query,
something like ...

SELECT * FROM SomeTable WHERE SomeColumn = WeekdayName(Weekday(Date, 0),
False, 0)

Note that the WeekDay function defaults to using vbSunday as the first day
of the week, while the WeekDayName function defaults to using
vbUseSystemDayOfWeek, so it's important to specify the same value for the
two function calls, otherwise you get unexpected results on a system where
Sunday is not the first day of the week.
 
T

train.fan#007

I'm not quite sure what it is that you want to do with the query. It
is not clear to me just what you mean by 'select' in this context. I'm
going to take a guess that possibly you want to assign the name of a
query to the record source property of a form? In that case, the code
might look something like so ...

Select Case WeekdayName(Weekday(Date, vbUseSystemDayOfWeek), False,
vbUseSystemDayOfWeek)
Case "Monday"
Me.sfrSomeSubFormControl.Form.RecordSource = "qryQueryForMonday"
Case "Tuesday"
Me.sfrSomeSubFormControl.Form.RecordSource = qryQueryForTuesday"
'etc
End Select

It's difficult to be sure without more information, but it sounds
quite probable that the goal could be achieved with a single parameter
query, something like ...

SELECT * FROM SomeTable WHERE SomeColumn = WeekdayName(Weekday(Date,
0), False, 0)

Note that the WeekDay function defaults to using vbSunday as the first
day of the week, while the WeekDayName function defaults to using
vbUseSystemDayOfWeek, so it's important to specify the same value for
the two function calls, otherwise you get unexpected results on a
system where Sunday is not the first day of the week.

Hi & thanks Brendan,
I should have made the question clearer.
Here goes again:-
I have a main Form, on which I have many sub-forms.

1 subFrom, I would like to be able to choose from a varible amount of
date based columns from one table eg driversName, 270507, 280507,
290507, 300507, 310507 etc.

I would like to have showing, on the subform, the driversname and todays
date column.
If you could help I will be well chuffed. thanks in advance
Exilescot.
 
Top