Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Paramter to a Query 1

Status
Not open for further replies.

kkitt

Programmer
Dec 1, 2002
122
US
I am trying to pass a parameter to a query based off a field on my form.

I am trying to get what is in red to come from the form, but it keep giving the popup asking for the parameter:

Thanks in advance


Code:
SELECT DISTINCT TOP 5 [qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate, [qryHistoryUniqueRecords (No Dup Phone #)].hstRepName, [qryHistoryUniqueRecords (No Dup Phone #)].hstCallType, qryCountTotalCalls.KntCalls AS [Total Calls], qryCountTalk.KntTalk AS Talked, qryCountMsg.KntMsg AS Msg, qryCountBusy.KntBusy AS Busy, qryCountWrongPhone.kntPhone AS [Wrong #], qryCountWrongAddr.KntAddr AS [Wrong Addr]
FROM ((((([qryHistoryUniqueRecords (No Dup Phone #)] LEFT JOIN qryCountTotalCalls ON ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate = qryCountTotalCalls.hstCallDate) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName = qryCountTotalCalls.hstRepName) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType = qryCountTotalCalls.hstCallType)) LEFT JOIN qryCountMsg ON ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate = qryCountMsg.hstCallDate) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName = qryCountMsg.hstRepName) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType = qryCountMsg.hstCallType)) LEFT JOIN qryCountBusy ON ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate = qryCountBusy.hstCallDate) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName = qryCountBusy.hstRepName) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType = qryCountBusy.hstCallType)) LEFT JOIN qryCountWrongPhone ON ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate = qryCountWrongPhone.hstCallDate) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName = qryCountWrongPhone.hstRepName) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType = qryCountWrongPhone.hstCallType)) LEFT JOIN qryCountWrongAddr ON ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate = qryCountWrongAddr.hstCallDate) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName = qryCountWrongAddr.hstRepName) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType = qryCountWrongAddr.hstCallType)) LEFT JOIN qryCountTalk ON ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType = qryCountTalk.hstCallType) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName = qryCountTalk.hstRepName) AND ([qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate = qryCountTalk.hstCallDate)
WHERE ((([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName)=[b][red][form]![frmpopCareRepCallHistory]![txtCareRepName][/red][/b]) AND (([qryHistoryUniqueRecords (No Dup Phone #)].hstCallType)<>"s"))
ORDER BY [qryHistoryUniqueRecords (No Dup Phone #)].hstCallDate DESC , [qryHistoryUniqueRecords (No Dup Phone #)].hstCallType;
 
Try taking the brackets off, since you have no spaces in the names they may not be needed, and that might be thowing it off.
 
I usually pass a parameter to a query through a function that is in the standard module.

Public RepName as string
Public Function ReturnRepName() as String
ReturnRepName = RepName
End Function

In the BeforeUpdate Event on the Form
RepName = Me.[txtCareRepName]

Query.
WHERE ((([qryHistoryUniqueRecords (No Dup Phone #)].hstRepName)=ReturnRepName())
 

Thanks for the quick respose, since this query is not in my VBA Code and is being called the "recordsource" for the form the function call was what I needed.

I have created other function call for queries, don't know why I did not think of it for this.

Thanks again for all the responses.
 
=[form[highlight]s[/highlight]]![frmpopCareRepCallHistory]![txtCareRepName]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top