saving default values

R

Rizza

I am not trying to have bad posting netiquette by reposting. It appears my
other two posts are dead. Here is my problem with more detail this time.

End goal: I am running a process which runs many queries, sub routines and
functions. I have many process variables used in the queries and such. I
have decided to store the values in the default value property of the text
boxes on a form. The form will be pass protected. Then I wish to make an
MDE to prevent any changes without a password. I have written the code to
update the default value of a textbox from a button. It seems I should be
able
to call code to change these values which it does. However, if I close the
form it does not retain the updated default values unless I make the changes
in design. My requirement is for the values to be modifiable from the
form and secure.

Running Access 2003
Code:
''' This code does not work
Private Sub btnCommit_Click()
Dim demRet As Integer
demRet = Me.txtDemRet
Me.txtDemRet.DefaultValue = demRet
'DoCmd.Save
DoCmd.Save acForm, "Controls"
'DoCmd.Close acForm, Me.Name, acSaveYes 'From Klatuu
End Sub

''' This code works
Private Sub btnCommit_Click()
Dim demRet As Integer
demRet = Me.txtDemRet
DoCmd.OpenForm "Controls", acDesign, , , acFormEdit
Forms!Controls!txtDemRet.DefaultValue = demRet
DoCmd.OpenForm "Controls", acNormal
DoCmd.Save
End Sub
 
D

Douglas J. Steele

I don't believe you'll be able to do it with an MDE.

Forms cannot be opened in Design view in MDEs, and the DefaultValue cannot
be set unless the form is open in Design view.
 
R

Rizza

Thank you Doug Steele for confirming that which I assumed.
Would anyone be able to point me to how I could secure my values and have
them updateable from a form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top