AllowEdits question

hjg

Registered User.
Local time
Today, 06:56
Joined
Aug 10, 2007
Messages
21
I'm writing a macro to allow edits on a sub-form called TmElpsd_sbfrm. The main form is called EDFrm. I locked editing on the TmElpsd_sbfrm. The macro is a SetValue function. I'm not sure what to put on the Item line. I looked at this page and thought it indicated: Me!Subform1.Form!ControlName.Enabled

If so, would my statement be this?: Me!TmElpsd_sbfrm!EDForm!AllowEdits.Enabled

Thank you.
 
I'm writing a macro to allow edits on a sub-form called TmElpsd_sbfrm. The main form is called EDFrm. I locked editing on the TmElpsd_sbfrm. The macro is a SetValue function. I'm not sure what to put on the Item line. I looked at this page and thought it indicated: Me!Subform1.Form!ControlName.Enabled

If so, would my statement be this?: Me!TmElpsd_sbfrm!EDForm!AllowEdits.Enabled
no. you actually use the word 'Form' to indicate you are now referring to the subform. i think '= True' is appropriate here:

Me!TmElpsd_sbfrm!Form.AllowEdits = True

i haven't used macros for a while. is SetValue what you are looking for?
 
no. you actually use the word 'Form' to indicate you are now referring to the subform. i think '= True' is appropriate here:

Me!TmElpsd_sbfrm!Form.AllowEdits = True

i haven't used macros for a while. is SetValue what you are looking for?

I think I found part of the problem. The container name of the subform is different from the subform name. So the container name is the one I want to use. That is ED_TmElpsd_Tbl. Still, the macro is halted, as "the object doesn't contain the Automation object 'Me.' If I take out Me! it says the "object doesn't contain the Automation object ED_TmElpsd_Tbl". I also tried: Me!ControlName.Enabled which is if you are on a subform referring to a control source (like enabled) on a subform.

I don't know if SetValue is the correct way. Bob Larson earlier helped me code a button to do the same thing on the form - but I cannot replicate it on the subform.
 
Did you not get the sample I uploaded for you with the changes to the subform as well using the For each ctl example?

Anyway, it all depends on where you are running the code from. If you are running it from a button on your subform you would not refer to the subform container, just using:

Me.AllowEdits = False
Me.AllowEdits = True

If you are running it from a button on the main form then it would be

Me.YourSubformContainerNameHere.Form.AllowEdits = False
 
Did you not get the sample I uploaded for you with the changes to the subform as well using the For each ctl example?

Yes, I got the edits and utilized them. They were very helpful. I was just not successful using the code for the 'Edit' button. I did try, however. This is what I did: I went in to On Click and put in this code, changing the cmdEdit to cmdEdit2. I called the button cmdEdit2. In the original code I changed all references to the EDForm to ED_TmElpsd_Tbl (the subform name). I set Allow Edits in the sub-form to Yes.

Private Sub cmdEdit2_Click()
On Error GoTo Err_Unlock_Editing_ED_TmElpsd_Tbl_Click

Dim ctl As Control
If Me.CmdEdit2.Caption = "Unlock To Edit" Then
For Each ctl In Me.Controls
If ctl.Tag = "lock" Then
ctl.Enabled = True
ctl.Locked = False
Me.CmdEdit2.Caption = "Lock Record"
End If
Next ctl

Else

For Each ctl In Me.Controls
If ctl.Tag = "lock" Then
ctl.Enabled = False
ctl.Locked = True
Me.CmdEdit2.Caption = "Unlock To Edit"
End If
Next ctl
End If


Exit_Unlock_Editing_ED_TmElpsd_Tbl_Click:
Exit Sub

Err_Unlock_Editing_ED_TmElpsd_Tbl_Click:
MsgBox Err.Description
Resume Exit_Unlock_Editing_ED_TmElpsd_Tbl_Click


End Sub


This didn't seem to do the trick. I'll try the other method that was suggested. Thanks so much for the advice. It's much appreciated!

Geoff
 
Last edited:

Users who are viewing this thread

Back
Top Bottom