default values

  • Thread starter Thread starter Guest
  • Start date Start date
User's don't input default values. Default values are set to be entered automatically, if
a user skips over the field. You can set default values at the form level for several
control types, including text boxes, combo boxes and list boxes (see the Data tab of the
properties for each of these controls). You can also set a default value in design view
at the field level for a table.

Tom Wickerath
Bellevue, WA. USA
__________________________________


Is there anyway to have a user input a default value in a form?
 
Kelly said:
Is there anyway to have a user input a default value in a form?

Do you mean, have the user specify what is to be the default value for a
control, for the remainder of the editing session? Sure; you can use
code to set the control's DefaultValue property at run time, and that
will persist until you change it or the form is closed. You'd have to
provide the user a means to do this, though. The only case I've seen,
though it's quite common, is to have the control automatically default
to the last value entered. You can do this with code in the form's
AfterUpdate event or the control's AfterUpdate event. Code looks
something like this:

Private Sub Form_AfterUpdate()

With Me![YourControlNameHere]
.DefaultValue = """" & .Value & """"
End With

End Sub

Just insert the name of the control in place of "YourControlNameHere".
 
Here is a little more information on assigning a Default Value of
control when entering multiple record entries in a single session.

The code needed for each control will depend on the datatype of th
field the control is bound to.

Code
-------------------
' Here is an example for a "Text" datatype control:
Me.ActiveControl.DefaultValue = "'" & Me.ActiveControl & "'"

' Here is an example for a "Numeric" datatype control:
Me.ActiveControl.DefaultValue = Me.ActiveControl

' Here is an example for a "Date/Time" datatype control:
Me.ActiveControl.DefaultValue = "#" & Me.ActiveControl & "#
 
R. Hicks said:
Here is a little more information on assigning a Default Value of a
control when entering multiple record entries in a single session.

The code needed for each control will depend on the datatype of the
field the control is bound to.

As it happens, code like this will work for all field types:

With <control reference>
.DefaultValue = """" & .Value & """"
End With

The DefaultValue property will be evaluated as a string and converted if
need be to the appropriate data type.
 
Newsgroups: microsoft.public.access
NNTP-Posting-Host: ns1.fluidata.com 216.38.218.34
Path: internal1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!border1.nntp.ash.giganews.com!firehose2!nntp4!intern1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!news2.euro.net!newsgate.cistron.nl!skynet.be!skynet.be!newsfeed00.sul.t-online.de!t-online.de!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
Lines: 1
Xref: intern1.nntp.aus1.giganews.com microsoft.public.access:75590

Thanks Dirk ...

Neat little trick, I saves the worry about the datatype and the
syntax.

RDH
 
Back
Top