Dynamic Sorting and Query

B

bw

I have a multiple reports that are formated pretty much the same. So I
thought if I could set the RecordSource to each report to a query that
goes with each report, I could then have one report do the work of many.

I have put code below (and more of course) in the Report Open Event.

1. The RecordSource is apparently not using the Query that I have
specified, although I get no errors. WHY?
2. When I try to set the GroupLevel ControlSource, I get the following
error:
"Microsoft Access can't find the field 'LastUpdate' referred to in
your expression." WHY?

If [Forms]![boxLastUpdated]![PW] = 1 Then
qryname = "qryLUA"
RecordSource = qryname
Me.GroupLevel(0).ControlSource = LastUpdate
Else
If [Forms]![boxLastUpdated]![PW] = 2 Then
qryname = "qryLUB"
RecordSource = qryname
Me.GroupLevel(0).ControlSource = LastUpdate
End If
End If
 
M

Marshall Barton

bw said:
I have a multiple reports that are formated pretty much the same. So I
thought if I could set the RecordSource to each report to a query that
goes with each report, I could then have one report do the work of many.

I have put code below (and more of course) in the Report Open Event.

1. The RecordSource is apparently not using the Query that I have
specified, although I get no errors. WHY?
2. When I try to set the GroupLevel ControlSource, I get the following
error:
"Microsoft Access can't find the field 'LastUpdate' referred to in
your expression." WHY?

If [Forms]![boxLastUpdated]![PW] = 1 Then
qryname = "qryLUA"
RecordSource = qryname
Me.GroupLevel(0).ControlSource = LastUpdate
Else
If [Forms]![boxLastUpdated]![PW] = 2 Then
qryname = "qryLUB"
RecordSource = qryname
Me.GroupLevel(0).ControlSource = LastUpdate
End If
End If


If LastUpdate is the name of a field in the report's record
source (as opposed to a VBA variable), the it needs to be in
quotes.
 
B

bw

Oh, thank you sir!


Marshall Barton said:
bw said:
I have a multiple reports that are formated pretty much the same. So
I
thought if I could set the RecordSource to each report to a query that
goes with each report, I could then have one report do the work of
many.

I have put code below (and more of course) in the Report Open Event.

1. The RecordSource is apparently not using the Query that I have
specified, although I get no errors. WHY?
2. When I try to set the GroupLevel ControlSource, I get the
following
error:
"Microsoft Access can't find the field 'LastUpdate' referred to
in
your expression." WHY?

If [Forms]![boxLastUpdated]![PW] = 1 Then
qryname = "qryLUA"
RecordSource = qryname
Me.GroupLevel(0).ControlSource = LastUpdate
Else
If [Forms]![boxLastUpdated]![PW] = 2 Then
qryname = "qryLUB"
RecordSource = qryname
Me.GroupLevel(0).ControlSource = LastUpdate
End If
End If


If LastUpdate is the name of a field in the report's record
source (as opposed to a VBA variable), the it needs to be in
quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top