Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default Value from another Text Box? 1

Status
Not open for further replies.

MichaelPos

IS-IT--Management
May 8, 2007
5
GB
Hi Guys

Is it possible to set Text Box “Default Value” as a value from another Text Box on the same open record? It seems to be very obvious question but I can’t figure it out or find any answer.


Thanks

Michal


 
From Microsoft help:

[tt]One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

=Forms!frmInvoice!txtShipTo

If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.[/tt]

However, I think you may find that using the After Update event of ControlA to set ControlB will suit better.


 
Hello

Yes. One way would be set the ControlSource property of your text box equal to the other text box contents. The same can be done using VBA instructions.

In the control source property of your box put the following.

= MyTextBoxName
 
How are ya MichaelPos . . .

Try:
Code:
[blue]   Me![purple][b][i]Textbox2[/i][/b][/purple].DefaultValue = Me![purple][b][i]Textbox1[/i][/b][/purple].DefaultValue[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 

Thanks guys for quick reply,

Remou:

That was my first thought, but it doesn’t work. Unless I am doing something terribly wrong hehe :). I’ve made sample database to test this mechanism:

-Table: Table1

-Fields:

ID
Name1
Name2

Form created by wizard (named FormTable1), in Name2 in Default Value I have entered: =[Forms]![FormTable1]![Name1]

And it doesn’t work :(

mhartman1:

I’m trying to do it on Form level to feed different fields in table, hence ControlSource doesn’t seem to be best idea, unless I didn’t get your idea hehe, but thanks for a tip anyway.

TheAceMan1:

I’ve tried to implement that code but without success. Do you use it as VBA Code procedure or as a value on Default Value field in properties of
 
Aceman's code is for VBA use


Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top