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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

as opposed to default

Status
Not open for further replies.

uscitizen

Technical User
Jan 17, 2003
672
US
let's say we have a database with 10 tables. each table holds different kinds of data, but has the same first two control fields and for simpicity let's agree to call them field_1 and field_2. another property of our data base configureation requires the following, namely on every record in every table we want two things to be true: field_1 will contain '123' and field_2 to contain 'xyz'.

my current approach has me keying '123' and 'xyz' as the default values for field_1 and field_2, respectively, in every table involved. so, when a user opens a table, the two fields are pre-populated with the desired contents. the data have been changed to simplify the question posed, but i think the motivation is clear enough.

so, i guess the question is: does there happen to be a niftier way of getting the same result?
 
My first thought:
If it's always the same, don't have it... Assume it's there, and if you need it for say a report, in the control source you can add it for the report...

Just my thought...

--James


junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
i forgot to add that there are reasons for wanting the data in those fields so i guess it's back to square 1.
 
ok... If you have, say a button to save the data (I alwas use a save button, that way I can do validation and then stuff like this)...

in the save button you can do some thing like this:
(assume the text box is named txbox1 and txbox2)

<Code Start>
if left(me!txbox1, 3) <> &quot;123&quot; then
me!txbox1 = &quot;123&quot; & me!txbox1
end if

if left(me!txbox2, 3) <> &quot;xyz&quot; then
me!txbox2 = &quot;xyz&quot; & me!txbox2
end if
'then code to save the record...
<Code End>

This is just one way of doing it...
Also, This is off the top of my head and un tested... So I may have gotten the syntex wrong... But hopefully you will understand what I'm tring to do...

--James


junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Default value for Field1 = 123
Default value for Field2 = xyz

Sub PushToEnd()
On Error Resume Next
Screen.ActiveControl.SelStart = Len(Screen.ActiveControl)
End Sub

Private Sub TextBox_GotFocus()
PushToEnd
End Sub

When TextBox gets the focus, it becomes the Screen.ActiveControl
Calling PushToEnd will move the cursor at the end of what's there...

This works if you use keys (not the mouse) to navigate through fields

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top