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

How to Allow User to Change Default Value

Status
Not open for further replies.

number2

Technical User
Oct 25, 2001
284
0
0
US
I have a memo feild which is given a default multiple sentance text value in my table.

I need to find a way for the end user to able to edit this default value. Can I code a button to change the default value when the user makes his changes and hits the button?

Thanks
 

This is a quick way to do it. Create a command button and then place the following code in the OnClick event.

Screen.PreviousControl.SetFocus
SendKeys "+{F2}"

This is using the Windows SendKeys statement and represents pressing the shift and F2 keys simultaneously when a field has the focus. When the user is on the memo field with the focus and they click the command button the Windows zoom function is invoked and a larger memo field is opened and the entire field is highlighted and when you begin typing on the keyboard the contents are deleted as the text is entered.
 
What I am trying to do is also the user to change and set the Default text which is entered into the feild via either the feild properties default value or the table's default value. Is there any way do do this?
 
Could you elaborate a little more for me.

Is the field going to be blank and you will ask the user to select a value based on some criteria?

Or will the field contain a default value and then you want the user to deleted it and add a new value?

Mike
 
I would like the user to be able to permanently update a default text paragraph in a memo feild.
 
OK, if I understand this correctly, when the user first views the record there will be some default value in the memo field. Then the user needs to edit or modify that value in some manner and add additional information. Then the edited value now becomes the new default value for future records?
 
This will work but is a little crude at this point. The default value property can only be 255 characters even if it is a memo field it will probably truncate beyond that limit. Try calling this procedure from a command button. Create a test table Table1 with a MyMemo memo field and then set a default value for the field. Create some records and then check the impact of this procedure.

Code:
Sub NewDefaultValue()

    Dim dbsdb1 As Database
    Dim tdfTable1 As TableDef
    Dim strNewDefault As String
    
    Set dbsdb1 = OpenDatabase("db1.mdb")
    Set tdfTable1 = dbsdb1.TableDefs!Table1
   
    tdfTable1.Fields!MyMemo.DefaultValue = InputBox  (strNewDefault)

    dbsdb1.Close

End Sub


 
Thanks for the help, it is a hard one, however it is a fairly important problem to solve. I need to give the user a default paragraph and then allow them to make permanent changes to the default. The default currently works fine however it is several sentances long, far greater than 256 characters. Is there no other way to reset the default to that of the users inpt into the field?
 
Why not just create a table to store the default value and a create a form so the users can edit it. Then in the OnCurrent event of your form that is linked to your memo field enter the following code.

***********************************************************
'Check to see if we are on a new record first
'Replace field and table names with your names

If Me.NewRecord Then
Me.YourMemoField = DLookup("[DefaultMemo]","tblDefaults")
End If

************************************************************

I use this method alot and it works well.

Dermot
 
I just ried that but failed. Thanks for the help everyone, but this one is beyond me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top