Combine Multiple Dates in Report

What was the exact error message? My guess would be that you have put the code in a Module or a Class, but it should actually be in the Form's module.

Just for clarity, what you actually wrote was still a parameterised query. The red bits indicate that it is -->
Parameterised in the sense that you are reference a control from within the SQL statement.

Yes, I did put the code in a Module, and run it as a Function!
Does it make any difference within a Form's module?

rabbit
 
Yep, it does. It needs to be in the Form module for it to run. Else it doesn't know what Me.[StartDate] is. Just move the whole function to the form's module and run it there.
 
Yep, it does. It needs to be in the Form module for it to run. Else it doesn't know what Me.[StartDate] is. Just move the whole function to the form's module and run it there.

You just got me going are you! OK !
Just wonder if I create another form which I will add a staff's name on + Start/End day, all I have to do is to change the SQL within?

rabbit
 
You mean to concatenate Staff Name based on Start/End Dates? If the SQL is different then yes you will need to amend it, and also this line:
Code:
        strConcat = strConcat & rst![StaffName]
 
You mean to concatenate Staff Name based on Start/End Dates? If the SQL is different then yes you will need to amend it, and also this line:
Code:
        strConcat = strConcat & rst![StaffName]

Sorry, not concatenate staff name with the start/end day.
through a form (contains Staff name text box, Start /End day text boxes), apply to a query as the criteria for 1) Staff Name 2) Lining. Then add the Concatenate function to the report..... or form module.....? By the way, back to the only Start/End day, you mean just add the function to the form module?

rabbit
 
Don't use the StaffName field, use the StaffID field. So yes you can add:
" AND StaffID = " & Me.StaffID


... to the SQL to filter by StaffID. It will only make sense if you Group By StaffID.

Yes, cut and paste the function into the form's module.
 
Don't use the StaffName field, use the StaffID field. So yes you can add:
" AND StaffID = " & Me.StaffID


... to the SQL to filter by StaffID. It will only make sense if you Group By StaffID.

Yes, cut and paste the function into the form's module.
Ok, let me charge my laptop first and I'll try it.
 
Yep, it does. It needs to be in the Form module for it to run. Else it doesn't know what Me.[StartDate] is. Just move the whole function to the form's module and run it there.
No, it prompts me with "Enter Parameter Value" ConcateRelatedvba (the function name), besides, I spot a [Datefield] in your code, not quite match any fields in my query.
 
Don't use the StaffName field, use the StaffID field. So yes you can add:
" AND StaffID = " & Me.StaffID

... to the SQL to filter by StaffID. It will only make sense if you Group By StaffID.

Yes, cut and paste the function into the form's module.

Thank you, finially I put this to work!
Thank you so much for all the helps!

Rabbit
 
I'm pleased to hear Rabbit.

What went wrong?

Spelling of my function:
First I used ConcateRelated,
then I add to the report ConcatedRelated!!!!!

Many years ago, when I was in colleage, I took computer science!
It took me overnight to debug a program with a mistake of "0" and "O"
I changed my major afterward!

Anyway thank you so much for all your help!
I am going to another program and want to ask some question about entry form!
Can I post it over the Forms Section, please if you can help me!
See you there: topic will be listbox rowsource from different tables.

Rabbit
 
Spelling of my function:
First I used ConcateRelated,
then I add to the report ConcatedRelated!!!!!

Many years ago, when I was in colleage, I took computer science!
It took me overnight to debug a program with a mistake of "0" and "O"
I changed my major afterward!
It happens to the best of us.

Anyway thank you so much for all your help!
I am going to another program and want to ask some question about entry form!
Can I post it over the Forms Section, please if you can help me!
See you there: topic will be listbox rowsource from different tables.
If it's a form related question then the Forms section is the place. Even if I'm not there to take a look there are many capable hands on here.
 

Users who are viewing this thread

Back
Top Bottom