A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

User Sets Control Default Value



 
 
Thread Tools Display Modes
  #1  
Old November 4th, 2009, 07:43 PM posted to microsoft.public.access.forms
JPC
external usenet poster
 
Posts: 18
Default User Sets Control Default Value

I would like my user to be able to set and lock default values for controls
in a data entry form so that repeated information is entered automatically.
I have a form that asks the user to enter data into a control. A command
button then runs code that sets the default value
[Me.ControlName.DefaultValue = Me.ControlName], and disables the control
[Enabled = False, Locked = True]. As long as the data contains numerals
only, it works just fine. If the data entered contains anything else, like
letters, spaces, or a hyphen, it doesn’t work correctly.

In the table design, this is a text field. Entering data directly into the
table works, as does a straight data entry form, without default values etc.
However when I insert the code for setting default values and disabling the
control, I am having problems.

In the form, if the user enters ABC-123 into the control, then clicks the
command button, the original entry is intact, and the control does get
disabled. But #Name? starts to display in the control for a new record. As
additional entries are made, the control for this field is left blank, and
#Name? appears to move down, and continues to display in the control for new
records. In the table, the original user entry of ABC-123 is saved in the
field for the first record entry only. This field is blank for additional
entries.

Any suggestions?

  #2  
Old November 4th, 2009, 07:48 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default User Sets Control Default Value

"JPC" wrote in message
...
I would like my user to be able to set and lock default values for controls
in a data entry form so that repeated information is entered
automatically.
I have a form that asks the user to enter data into a control. A command
button then runs code that sets the default value
[Me.ControlName.DefaultValue = Me.ControlName], and disables the control
[Enabled = False, Locked = True]. As long as the data contains numerals
only, it works just fine. If the data entered contains anything else,
like
letters, spaces, or a hyphen, it doesn’t work correctly.

In the table design, this is a text field. Entering data directly into
the
table works, as does a straight data entry form, without default values
etc.
However when I insert the code for setting default values and disabling
the
control, I am having problems.

In the form, if the user enters ABC-123 into the control, then clicks the
command button, the original entry is intact, and the control does get
disabled. But #Name? starts to display in the control for a new record.
As
additional entries are made, the control for this field is left blank, and
#Name? appears to move down, and continues to display in the control for
new
records. In the table, the original user entry of ABC-123 is saved in the
field for the first record entry only. This field is blank for additional
entries.


Force quotes around the DefaultValue setting:

Me.ControlName.DefaultValue = _
Chr(34) & Me.ControlName & Chr(34)


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.