Hi Mark
I hope Larry's response has answered your question.
To further elaborate, the DefaultValue property is seen as a string which is
then evaluated as an expression. For example:
MyControl.DefaultValue = "Date()"
would cause the Date function to be called, which would return the current
date.
Similarly,
MyControl.DefaultValue = "8/1/04"
would cause the string to be evaluated as the expression "8 divided by 1
divided by 4", which would return the result 2.
Presumably this would NOT be what was intended. To get the intended result,
put the string in quotes:
MyControl.DefaultValue = """8/1/04"""
Or, to make this more readable, use Larry's suggestion and declare a
constant for the quote character:
Const cQuote = """"
MyControl.DefaultValue = cQuote & "8/1/04" & cQuote
For what you want to do, your default values will be derived from variables
(or recordset fields), not constants, so you might do something like this:
With Me.RecordsetClone
.MoveLast
Me.Field1.DefaultValue = cQuote & .Field1 & cQuote
Me.Field2.DefaultValue = cQuote & .Field2 & cQuote
... etc
End With
You can also use the Form_AfterUpdate procedure to set change default values
to the new data as new records are added.
(Note that some sources suggest you enclose dates in hash signs (#), but I
recommend quotes as preferable because the conversion of a quoted date will
respect your regional date format settings, while #8/1/04# will always be
interpreted as the US format of mm/dd/yy)
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
you could set the DefaultValue of a textbox to "Da
"Mark" <mm*****@earthlink.net> wrote in message
news:ZE***************@newsread2.news.atl.earthlin k.net...
Graham,
Thank you for the response!
Would you explain further your last sentence about the DefaultValue
property is always a string expression?
If I wanted the following default values in different fields, what would I
set the DefaultValue to:
4.5
$8.75
5/10/04
Miles Shipping Company
Thanks,
Mark
"Graham Mandeno" <Gr************@nomail.please> wrote in message
news:ei**************@tk2msftngp13.phx.gbl... Hi Mark
If you set the values in the new record by setting the DefaultValue for
each control, instead of the Value, then the new record will not become dirty
until the user types in some changes.
The one catch is that the DefaultValue property is always a string
expression, so strings and dates must be enclosed in quote marks.
--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand
"Mark" <mm*****@earthlink.net> wrote in message
news:Qb****************@newsread3.news.atl.earthli nk.net... When my form goes to a new record, I have a procedure that copies the
last record added to the form's underlying table into the form. The intent
is that a series of new records may have the same data in many of the fields so
I paste in the same values of the previous record and then edit what needs edited
in the new record saving much retyping of the same data. Doing this however
creates the definite possibility of creating a duplicate record. If after copying
the previous record, no fields are edited, a duplicate record of the
previous record is created. I'm looking for a way to detect if the new record has been
edited after a copy of the previous record has been added to the form. I
checked the Dirty property and the form is dirt after adding the copy of the
previous record so using the dirty property seems to be out. Does anyone have any idea
on what I can do?
Thanks!
Mark