Default Value

  • Thread starter Thread starter manrav
  • Start date Start date
M

manrav

Guest
:confused: :confused:

I have 2 text boxes. Text0 and Text2.

When I click a button, I would like the value of tex2, to be the default value of text0. Below is the code I am using. The problem is that once i close the form the default value resets to nothing. How do i get the default value to stay. Any Help, tips, greatly appreciated..

Private Sub Command4_Click()
Dim defvalue
defvalue = Me.Text2
MsgBox defvalue

Dim x2 As Control
Set x2 = Me.Text0



With x2
.SetFocus
.Enabled = True
. DefaultValue = defvalue

End With

End Sub
:confused:
 
Default value

The reason the value in Text0 disappears may be that it is an unbound field, meaning it is not getting data from a table/query but needs to be re-assigned everytime you open the form.

If this is the case, open design view, select Text0, on the Data Tab set Default Value to: =[Text2]

Then in design view, select Text2, on the Event Tab, put the following in the AfterUpdate Event:

Me.Text0 = Me.Text2

That assures that after you update Text2, the same value will appear in Text0.

Good Luck
 
Thanks,
I thought that may be the case, Just wanted to confirm. I have set the Text bx to a table as a bound control and it works. Thanks for the Tip..
 

Users who are viewing this thread

Back
Top Bottom