Setting allows permissions for a subform in datasheet view

G

Guest

I have some VBA coding (in form_current) that sets allowedits for a sub-form
depending on certain conditions. The coding looks like:

DDAssigned.Form.AllowEdits = True

where DDAssigned is the control name of the sub-form on the main form. This
works fine, except when the user is viewing the main form in datasheet view.
In this case I get the error:

2455

"You entered an expression that has an invalid reference to the property
Form/Report"

The problem is that in datasheet view the user can click the "+" sign on the
left edge of the form to see and manipulate the sub-form.

So, I guess I either need to find a way to set the permissions of the
sub-form in datasheet view (preferred), or find a way to removed the "+" from
the form in datasheet view.

Thanks.

Regards,
Leif
 
G

Guest

Hi Leif
References to subforms can be a real pain. The syntax of dots and
exclamation marks can be difficult to get right. I found a good way to get
it right is to use the build function in Access to get the correct code.

If you are running the code from the main form, select any text box and go
to the default value. Right click and select build. You can then create the
correct syntax by navigating to the AllowEdits property of the subform. Just
copy the text, Cancel the build box and paste it into your VBA. Make sure
the default in the text box is blank. You only used that to fire up the
Build functionality. You can actually start it from a number of places but
unfortunately not in VBA.

Hope that helps.
 
G

Guest

Hi Neville,

Thanks for your response. I'm pretty sure syntax is not my issue. If it
was it would not work in form or datasheet view.

I tried moving the code from the main form to the subform. I'm using the
subform open event. Each time you click the "+" on the main form it is a
separate open event in the subform. This works sometimes. After the open it
works. However, if I move to an opened subform in the main form datasheet
view, where I want the allowedits to be false, then move to a different
subform, the logic seems to fail.

I'm beginning to think I should "turn-off" the "+" (if possible) in the main
form datasheet view rather than deal with the issues. If the user needs to
change something in the subform I can tell them they must do so in the main
form form view.

Regards,
Leif
 

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