Use a Report to print VBA results

R

Rookie Dan

I have a form where I enter 2 numbers for a beginning
month and day then 2 more for an ending month and day.
A VBA procedure then selects records from table "A" if
the Birthdate field has a month and day between values
entered on a form. It uses a "Do Until rst.EOF()" loop to
inspect each record and it always selects the correct
records.
Now how do I get the selected records to go to an Access
report?
Thanks in advance.
 
A

Allen Browne

Create a query with a calculated field that uses your function to select the
data, e.g.:
GetBirthdays(...

Use the query as the source for the report.
 
F

Francesc Hervada-Sala

Rookie Dan said:
Thanks for the help but I'm still lost.
1. the "sub()" has "Debug.Print birthdate" the end of the
Do loop. Is this what I need to physically sends the
birthdate to the Report?
2. How do I build a calculated field that uses the sub?
When I tried "GoodRecords: GetBirthdays()" it kept saying
there was an incorrect number of arguements.
Thanks in advance.
Dan

it must be a function, not a sub, such as:

Public Function GetBirthdays( ...parameters... ) As Variant

....

GetBirthdays = ... 'assigns return value

End Function

at a calculated field in the query:

Birthdays: GetBirthdays( ... )



HTH


Francesc,
 

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