passing parameter to text field function (UDF)

A

AkAlan

Can a text field have a User Defined Function as its record source which has
a parameter passed to it in an MS Access Project?


Using the Customers and Orders scenerio for what I'm trying to accomplish, I
want to display a record for every Customer and I have two fields in every
row with the Min and Max date of all the Orders from the Customer. I created
a function that returns the Min and Max Dates as MinOrderDate and
MaxOrderDate grouped by CustomerId. How do I get the text fields to display
the dates using the current rows CusomerId? Before upgrading from an mdb I
used the following to get the correct results for the Min field:

=DMin("[OrderDate]","tblOrders","[CustomerId] = '" &
[Forms]![frmCustomerAnalyze]![CustomerId] & "'")

This still works but is painfully slow. I'm sure I can have the SQL server
crunch and return the values much faster, I just don't know how. Here is what
I put in the On Load property of the form:

Me.txtFirstOrder.RecordSource = "SELECT MinOrderDate from fn_CustOrderDates
where [CustomerId] = " & Me.CustomerID

I think I'm close but am losing patience with my lack of syntax knowledge.

I would be glad to provide any more info if it would help solve my problem.
Thanks for helping.
 

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