Update Form Recordsource Crosstab Query while in form....

G

Guest

I have the following crosstab query called [BuyerIn] which is the
recordsource for my form. The purpose of the query is to show the best time
to call my buyers back. It counts how many times I got a hold of them in my
call log table and groups by hour of the day.

What I would like to do is have a button on the form that will update the
form to show when the worst time to call is. Either by changing the
recordsource query to another query with BuyerAtDesk = False, or somehow code
it in sql. I have tried using a parameter in that criteria and linking it to
the grpButtons but have not had any sucess getting it to work in my form.

So, is there a way to change the record source to another query?
Or hard-code the query to run when opening the form?

Thanks,
MikeZz

WHERE (((Buyers.BuyerFilter)=True) AND ((ContactType.BuyerAtDesk)=FALSE))

TRANSFORM Count(Hour([CallLog]![LogTime])) AS Expr1
SELECT DatePart("h",[LogTime]) AS [Order], Format(([LogTime]),"h am/pm") AS
Hours
FROM ContactType INNER JOIN (Buyers INNER JOIN CallLog ON Buyers.BuyerID =
CallLog.BuyerID) ON ContactType.ContactTypeID = CallLog.CallType
WHERE (((Buyers.BuyerFilter)=True) AND ((ContactType.BuyerAtDesk)=True))
GROUP BY DatePart("h",[LogTime]), Format(([LogTime]),"h am/pm"),
Buyers.BuyerFilter, ContactType.BuyerAtDesk
ORDER BY DatePart("h",[LogTime])
PIVOT Buyers.ShortName;
 
G

Guest

you can set the recordsource property to your first query which will show
when you open the form. Then put this code under a commandbutton to switch
queries. Or you can just put this code under the form's On Open event and let
it set the recordsource when it runs.
Like this:

Private Sub Form_Open(Cancel As Integer)

Me.RecordSource = "qryCross2"

'or if you want to change another form's recordsource you use
'form_<name of form>.RecordSource = ...

Form_Form1.RecordSource = "qryCross2"

End Sub
 

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