default value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to write in visual basic a script to set the default value as the value last entered. One field is a numerical value and the other is a text value
 
I am trying to write in visual basic a script to set the default value as the value last entered. One field is a numerical value and the other is a text value

The DefaultValue property is a text string (regardless of the field's
datatype). In a Form's AfterUpdate event use

Me!txtMyTextbox.DefaultValue = Chr(34) & Me!txtMyTextbox & Chr(34)

Chr(34) is " so this will set the DefaultValue property to

"56"

if the user types 56 into the textbox.
 
John Vinson said:
The DefaultValue property is a text string (regardless of the field's
datatype). In a Form's AfterUpdate event use

Me!txtMyTextbox.DefaultValue = Chr(34) & Me!txtMyTextbox & Chr(34)

Chr(34) is " so this will set the DefaultValue property to

"56"

if the user types 56 into the textbox.

I used the above and it worked on one field. I tried to add another one just below it and it didn't work for that one. Can you only have one action per forms afterupdate event?

Another problem I am having is that one of my fields on this form is a field from a select query. The name for that field is break.team where the field is team and the table is break. Setting the default value using the method above will not work for this field either
 
I used the above and it worked on one field. I tried to add another one just below it and it didn't work for that one. Can you only have one action per forms afterupdate event?

The Event line on the form design window should show [Event
Procedure], and you should have the suggested line in the VBA code for
the event. This subroutine can contain as many lines as you need.
Another problem I am having is that one of my fields on this form is a field from a select query. The name for that field is break.team where the field is team and the table is break. Setting the default value using the method above will not work for this field either

Please post your code. You maybe should be setting the Default
property of the *textbox* bound to this field, rather than trying to
set the default of the field itself.
 
Back
Top