Passing a parameter to a query

Keith

Registered User.
Local time
Today, 02:25
Joined
May 21, 2000
Messages
129
For some hours now I have been researching how to pass a parameter to a query in VBA. I can't get my head around it - I must be thick.
I have a function that when called transfers a query recordset to an excel spreadsheet then emails it. At the end of the function I use code to write the date sent to a table. Each time the function is called I only need records in the query that have been modified since the last time the function was called. I have a field in the query 'LastModified' with a criteria '>[Enter Date]'. I then look up the date in the table and enter it manually. I know how to look up the last date sent in table using code but getting the >#SomeDate# in the query with VBA is causing my white hair to get even whiter.
Code:
    DoCmd.TransferSpreadsheet acExport, , "qryUpdateWebmaster", _
        "C:\Submariners\Updates_Sent\" & fname & ".xlsx", True, "Webmaster_Update"
 
Last edited:
Solved, Just the fact that I posted the question made something click. I added the criteria to the query grid highlighted in Blue in the SQL view of the query.
Code:
SELECT tblMembers.MemberID, tblMembers.LastName, tblMembers.Initials, tblMembers.FirstName, tblMembers.DateOfBirth, tblMembers.Rate, tblMembers.OffNum, tblMembers.Medals, tblMembers.Served, tblMembers.Boats, qryConcatBranch.Branches, tblMembers.Comments, tblMembers.DateJoined, tblMembers.DateLeft, tblLookUpStatus.Status, tblMembers.EMAIL, tblMembers.DetailsForWeb, tblMembers.EmailForWeb, tblMembers.LastModified
FROM tblUpdateDate, (tblMembers INNER JOIN qryConcatBranch ON tblMembers.MemberID = qryConcatBranch.MemberID) INNER JOIN tblLookUpStatus ON tblMembers.Status = tblLookUpStatus.ID
[COLOR="Blue"]WHERE (((tblMembers.LastModified)>[tblUpdateDate].[UpdateDate]) AND ((tblUpdateDate.UpdateType)="webmaster"))
ORDER BY tblMembers.LastModified[/COLOR];
 

Users who are viewing this thread

Back
Top Bottom