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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|