Form unlocking problems (1 Viewer)

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
I am amending an existing system.
There is a sub form FoPenSubOrder that is used on several forms.

On one form there is an unlock button to allow amendments to the sub form. The main form is called foPenOrder. The code for allowing amendments is in the click event for a command button

DoCmd.Save acForm, "foPenOrder"
[FoPenSubOrder].Form.AllowEdits = True
[FoPenSubOrder].Form.AllowDeletions = True
[FoPenSubOrder].Form.AllowAdditions = True

This works fine.

I am attempting to do the same in another form , foPenOrderAndPayments.
I have created a command button and in the click event I have the following code which is the same as above except for the DoCmd.Save bit

DoCmd.Save acForm, "foPenOrderAndPayments"
[FoPenSubOrder].Form.AllowEdits = True
[FoPenSubOrder].Form.AllowDeletions = True
[FoPenSubOrder].Form.AllowAdditions = True

This doesn't work. any ideas why?
 
Last edited:

moke123

AWF VIP
Local time
Today, 10:04
Joined
Jan 11, 2013
Messages
3,852
DoCmd.Save acForm, "foPenOrder"
[FoPenSubOrder].Form.AllowEdits = True
[FoPenSubOrder].Form.AllowDeletions = True
[FoPenSubOrder].Form.AllowAdditions = True

This works fine.

I am attempting to do the same in another form , foPenOrderAndPayments.
I have created a command button and in the click event I have the following code which is the same as above except for the DoCmd.Save bit

DoCmd.Save acForm, "foPenOrderAndPayments"
[FoPenSubOrder].Form.AllowDeletions = True
[FoPenSubOrder].Form.AllowAdditions = True

they are not the same. In the second one you left out allow edits.

Also saving the form object? if your intending to save the forms record use me.dirty = false. You may also want to be more specific and use ME as in
Me.[FoPenSubOrder].Form.AllowEdits = True
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
they are not the same. In the second one you left out allow edits.

Also saving the form object? if your intending to save the forms record use me.dirty = false. You may also want to be more specific and use ME as in
Me.[FoPenSubOrder].Form.AllowEdits = True

It is there it's just my copy and paste was rubbish
I have tried Me.[FoPenSubOrder].Form.AllowEdits = True and also [Forms]![FOPenOrderAndPayments]![FoPenSubOrder].Form.AllowEdits = True

Neither work
As far as the save goes I have inherited the application and it was in the original code for the first form so I copied it across. I've no idea why it is in there either.
Bottom line is I have the 2 forms with the same sub form and the same code in each of the main forms to unlock the sub form. The original form works my copy of it doesn't
 

JHB

Have been here a while
Local time
Today, 15:04
Joined
Jun 17, 2012
Messages
7,732
..
Bottom line is I have the 2 forms with the same sub form and the same code in each of the main forms to unlock the sub form. The original form works my copy of it doesn't
Is the main form of your copy locked?
Else post your database or a stripped down version of it, with some sample data.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:04
Joined
May 7, 2009
Messages
19,175
create a copy of your subform, rename the copy and use this as subform of your new form.
the reason is that you only have many Reference to the same subform but Points to one object.
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
Is the main form of your copy locked?
Else post your database or a stripped down version of it, with some sample data.

The attributes for the main form were set to no for allow edits, deletions and additions. The same fields for the first form were all set to yes so I thought I had cracked it.

Changed them to yes and it still doesn't work.
I have noticed however that there are differences between the two main forms.
When called from the previous form the form that wrks is called thus

DoCmd.OpenForm "FOPENorder", , , , acFormAdd, , Me.strCLIENT

and the form that doesn't work is called thus

DoCmd.OpenForm "foPenOrderAndPayments", , , "strOrderNumber='" & Me.strOrderNumber & "'", acFormEdit, acWindowNormal, "payment"

Also the form that doesn't work seems to have a filter toggle. I have no idea what this is for and seems to call some random record when used.

If I get no further with this I'll strip down the application and post as suggested
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
create a copy of your subform, rename the copy and use this as subform of your new form.
the reason is that you only have many Reference to the same subform but Points to one object.
I'll try that. Just becomes a pain when making future amendments I guess having to change multiple forms rather than 1
 

moke123

AWF VIP
Local time
Today, 10:04
Joined
Jan 11, 2013
Messages
3,852
you should also check that the subform containers have the same name. It's possible that they show the same form but have a different name.
 

missinglinq

AWF VIP
Local time
Today, 10:04
Joined
Jun 20, 2003
Messages
6,423
The attributes for the main form were set to no for allow edits, deletions and additions. The same fields for the first form were all set to yes so I thought I had cracked it.

Changed them to yes and it still doesn't work.
Can you edit a Record in the Main Form? If it's Read-Only, for any reason (such as being based on a mutli-table, Read-Only Query) the Subform will also be Read-Only.

Also, you're passing 'payment' as an OpenArg when opening the errant Main Form...what is being done with this by this Form?

Linq ;0)>
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
you should also check that the subform containers have the same name. It's possible that they show the same form but have a different name.

Not sure what you mean about subform containers. Do you mean controls? It's the same subform so presumably all controls are named the same.
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
Can you edit a Record in the Main Form? If it's Read-Only, for any reason (such as being based on a mutli-table, Read-Only Query) the Subform will also be Read-Only.

Also, you're passing 'payment' as an OpenArg when opening the errant Main Form...what is being done with this by this Form?

Linq ;0)>

The main form contains details about the main order the sub form contains the order details. I'm not sure if you can edit anything on main form but I'll go have a look.

The system I'm amending has some pretty weird design. I think the "payments" arg is used in a called piece of code. There is a third form that uses same subform and the main form tothat has "deposit" passed over. The called piece of code uses this to decide what to do.
 

missinglinq

AWF VIP
Local time
Today, 10:04
Joined
Jun 20, 2003
Messages
6,423
Not sure what you mean about subform containers. Do you mean controls? It's the same subform so presumably all controls are named the same.

Not so at all! Each time a Form is placed on a Main Form as a Subform, Access assigns a name to the Subform Control (the 'container') and this may or may not be the same name on different Forms.

Linq ;0)>
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
Not so at all! Each time a Form is placed on a Main Form as a Subform, Access assigns a name to the Subform Control (the 'container') and this may or may not be the same name on different Forms.

Linq ;0)>
Ah OK - If I open both the main forms then the selection type for the subform are both the same as is the source object. Is this what you mean. Incidentally I'm also looking at arnelgp idea of creating a copy. In this case the selection types are both the same but the source object is different. I can't get this to work as it doesn't like [FoPenSubOrderCopy].Form.AllowEdits = True. FoPenSubOrderCopy is the name of the copied form - it says it ca't find it. Presumably because the selction type says it's FoPenSubOrder.

I'm confused!
 

moke123

AWF VIP
Local time
Today, 10:04
Joined
Jan 11, 2013
Messages
3,852
Thats why using the me keyword is good. Intellisense will bring up the subform container name as you type it ensuring its correct. If you slect the outer edge of the subform container the name should show in the properties panel. the source object may or may not be the same.
Bear in mind that you can use code to change the sourceobject of a subform control but that wont change the name of the of the container.
 

Attachments

  • Capture.JPG
    Capture.JPG
    40.6 KB · Views: 38
Last edited:

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
Thats why using the me keyword is good. Intellisense will bring up the subform container name as you type it ensuring its correct. If you slect the outer edge of the subform container the name should show in the properties panel. the source object may or may not be the same.
Bear in mind that you can use code to change the sourceobject of a subform control but that wont change the name of the of the container.

Yep tried the ME. and ME!. Intellisense works on ME. so pretty sure everything fine there.
Check the container and they both use same.
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
I've read somewhere about this could be caused by various things (controls set to not allow it etc), selection/query has an outer join.

Neither of the above applies.
I've also read
"If your Record Source for the form is a query that has joins, but
the join is not on the primary key of one of the tables, you probably
will not be able to edit the data."
Well this does apply. My "query" has an inner join not on the primary key.
Could this be the problem

Going back to the main form that works with the (identical) subform - this has the same query. The query is part of the record source. The difference between the 2 is that when the first form is loaded the sub form is empty. The data is added when the user clicks a "copy template" with an append query.

On the 2nd main form that doesn't work the sub form is populated by passing over a "where" parameter

I've started rambling as this is getting to me!
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
create a copy of your subform, rename the copy and use this as subform of your new form.
the reason is that you only have many Reference to the same subform but Points to one object.

I've tried this and it's opened a can of worms! Although it appears to work it is throwing up a load of errors that I wasn't getting before the name change. I think this will take up more time to fix than fixing the original issue.
 

ryetee

Registered User.
Local time
Today, 14:04
Joined
Jul 30, 2013
Messages
952
OK I've found another control that had the form locked.
I'd changed the form to allow additions edits and deletions but hadn't changed the subform locked attribute(?) to no. I have now and it seems to work
 

Users who are viewing this thread

Top Bottom