If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Default Value as last date in a table?
I have a form that among other things filters a query by a start date and end
date. The start date default value is fixed. The end date field though I would like the default value to be calculated based on the last date in the table the query is based on. I have tried max, dmax, last, and others in the "default value" field and never can get it right, I always get an error, I'm sure it has somethign to do with the quotes (I'm quotationally impaired apparently.... ) My table is sales and field is Month End, what exactly do I put in the default value box to fill this in automatically? Thanks |
#2
|
|||
|
|||
Default Value as last date in a table?
Put the DMax for the default of the text box on the form that is bound to
your table field, not in the table. -- Build a little, test a little. "Robbro" wrote: I have a form that among other things filters a query by a start date and end date. The start date default value is fixed. The end date field though I would like the default value to be calculated based on the last date in the table the query is based on. I have tried max, dmax, last, and others in the "default value" field and never can get it right, I always get an error, I'm sure it has somethign to do with the quotes (I'm quotationally impaired apparently.... ) My table is sales and field is Month End, what exactly do I put in the default value box to fill this in automatically? Thanks |
#3
|
|||
|
|||
Default Value as last date in a table?
yes, that is what I am doing. I can plug a number in manually and it works
as intended, any use of Dmax that I can come up with results in error in the box instead of the intended date. "KARL DEWEY" wrote: Put the DMax for the default of the text box on the form that is bound to your table field, not in the table. -- Build a little, test a little. "Robbro" wrote: I have a form that among other things filters a query by a start date and end date. The start date default value is fixed. The end date field though I would like the default value to be calculated based on the last date in the table the query is based on. I have tried max, dmax, last, and others in the "default value" field and never can get it right, I always get an error, I'm sure it has somethign to do with the quotes (I'm quotationally impaired apparently.... ) My table is sales and field is Month End, what exactly do I put in the default value box to fill this in automatically? Thanks |
#4
|
|||
|
|||
Default Value as last date in a table?
NM, finaly got it
DMax("[Month End]","[sales]") I tried everything but that, the quotes are pure heck in this stuff! "Robbro" wrote: yes, that is what I am doing. I can plug a number in manually and it works as intended, any use of Dmax that I can come up with results in error in the box instead of the intended date. "KARL DEWEY" wrote: Put the DMax for the default of the text box on the form that is bound to your table field, not in the table. -- Build a little, test a little. "Robbro" wrote: I have a form that among other things filters a query by a start date and end date. The start date default value is fixed. The end date field though I would like the default value to be calculated based on the last date in the table the query is based on. I have tried max, dmax, last, and others in the "default value" field and never can get it right, I always get an error, I'm sure it has somethign to do with the quotes (I'm quotationally impaired apparently.... ) My table is sales and field is Month End, what exactly do I put in the default value box to fill this in automatically? Thanks |
#5
|
|||
|
|||
Default Value as last date in a table?
|
#6
|
|||
|
|||
Default Value as last date in a table?
On Thu, 18 Mar 2010 10:50:24 -0700, Robbro
wrote: NM, finaly got it DMax("[Month End]","[sales]") I tried everything but that, the quotes are pure heck in this stuff! They take some getting used to, but the key is that all of the domain functions (DMax, DLookUp, DCount etc.) take three *text strings* as arguments: the field to be summed (or looked up or counted); the name of the table or query in which to look; and an optional third parameter which is a string containing a valid SQL WHERE clause (without the word WHERE). These strings can be string literals - in quotes - or string variables, but they do need to be strings. For instance you could use Dim strField As String Dim strTable As String Dim strCrit as String strField = "[Month End]" strTable = "[sales]" strCrit = "[SalesDate] = #" & DateSerial(Year(Date), 1, 1) & "#" something = DMax(strField, strTable, strCrit) would find the maximum value of the Month End field this year to date. This would give exactly the same results (less readably for the code!) if you use string literals: DMax("[Month End]", "[sales]", "[SaleDate] = #1/1/2010#") -- John W. Vinson [MVP] |
Thread Tools | |
Display Modes | |
|
|