This command is not available in .mde, .accde etc (1 Viewer)

mahenkj2

Registered User.
Local time
Today, 09:55
Joined
Apr 20, 2012
Messages
459
I have used following code in a form to change a text box on another form's default value to change.

Code is working fine but when I convert the .accdb file to .accdr, it says "Error 7802 This command is not available in .mde, .accde"

I understand it might be due to I am opening another form in design view, but then without doing that how I can accomplish this.

Many thanks for your help.


If Not IsNull(Me.txtNewDefault) Then

DoCmd.OpenForm "frmMarkFinished", acDesign, , , , acHidden
Forms!frmMarkFinished.txtContainerWeight.DefaultValue = Me.txtNewDefault
DoCmd.Close acForm, "frmMarkFinished", acSaveYes
DoCmd.Close acForm, "frmChangeDefault"

Else
MsgBox "Please enter a value to proceed.", vbInformation, "No value to save"
Me.txtNewDefault.SetFocus

End If
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 23:25
Joined
Feb 28, 2001
Messages
27,186
You cannot use self-modifying code in a pre-compiled database file. The REAL reason is that you want to change something (by going into design view) when you already told Access you weren't going to change it (by saving as an .MDE or .ACCDE file). Access believed you when you said to save it.
 

mahenkj2

Registered User.
Local time
Today, 09:55
Joined
Apr 20, 2012
Messages
459
Thanks.

But, then how I can change a default value of a field of a form. I believe there should be some way to do so.

best regards.
 

boblarson

Smeghead
Local time
Yesterday, 21:25
Joined
Jan 12, 2001
Messages
32,059
Thanks.

But, then how I can change a default value of a field of a form. I believe there should be some way to do so.

best regards.

You can simply use

Me.ControlNameHere.DefaultValue = "Whatever"

Text in quotes, dates in octothorpes(#) and numbers without anything.

It won't keep it permanently but it will for the session that the form is open. But you can save preferences to a table and then load them at the time you need.
 

mahenkj2

Registered User.
Local time
Today, 09:55
Joined
Apr 20, 2012
Messages
459
Thanks a lot Bob for your reply.

Me.ControlNameHere.DefaultValue = "Whatever"

This form opens for a short while just to update a field of table, is a pop up form.There is a field in which I need to keep some value whenever this form opens for that user.

Now with your suggestion above, either I feed a value myself in my field or type default value in another field is same thing. My aim was to keep user free for long time once he sets his target default value. So, defalut value should work even after closing & opening the form again.

best regards.
 

pr2-eugin

Super Moderator
Local time
Today, 05:25
Joined
Nov 30, 2011
Messages
8,494
Mahenkj2, that still is possible using Bob's code right? You can use the same method in a Form Open/Load (whichever is appropriate).. I am sure it will place the default value.. Where is the code running from?
 

mahenkj2

Registered User.
Local time
Today, 09:55
Joined
Apr 20, 2012
Messages
459
Thanks all, I am giving a try to your suggestions.
 

Users who are viewing this thread

Top Bottom