Share via

Setting A Property On A SubForm Control

Anonymous
2013-07-01T23:05:25+00:00

This is driving me to despair. I've read so many MS Access sites trying to solve what appears to be a common difficulty in setting the property of a control on a sub-form using WIN7/Access 2013 (not a web-based site)

Main Form is [fmDeliveryNote] and Sub-form is [fmDeliveryDetails] and there is a control on the sub-form [UnitPrice]. I need to construct  Macros on the main form that will make [UnitPrice] on the sub-form Visible or Not Visible. As I do not do a lot of database construction I only have a moderate  ability at Macro level and not VB.

According to all advice the SETPROPERTY settings should be-

Control Name [fmDeliveryDetails].Form![UnitPrice]

Property [Visible]

Value [False] or [True]

This gets met with a "Control  misspelled or doesn't exit error message".  I have tried every possible permutation with/without the Forms! identifier bangs(!) and/or periods (.) and all sorts of full or partial syntax. I have checked that I  am using the correct sub-form control name. If I drop the [UnitPrice] bit then the macro does make the whole sub-form invisible/visible so at least the sub-form is recognised but the [UnitPrice} suffix is causing the problem.

Using the SETVALUE property instead of SETPROPERTY and using  ITEM=[fmDliveryDetails![UnitPrice] EXPRESSION [Visible=False] actually does recognise the control BUT only turns the first instance of [UnitPrice] from a previous value into a Zero.

I know this question has been asked many times but it seems to cause a lot of problems.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-07-02T22:13:50+00:00

Perhaps this would help explain about the syntax for referring to subforms/subreports.

http://www.btabdevelopment.com/ts/ewtrhtrts

Just to note - forms are meant for on screen interaction and reports are optimized for printing.  You can programatically make something disappear on either.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2013-07-02T16:40:18+00:00

    I may have found a answer.  From another site I found and copied a bit of code which, using my own form names, looks like this -

    Me.fmDeliveryDetails.Form.Controls("UnitPrice").ColumnHidden = True

    fmDeliveryDetails is my subform and UnitPrice is the field I want to hide when the record is printed. I have been able to convert the record into a report and printout with the prices not showing but it does mean having extra objects and having to change both forms if any changes are required.

    I cannot claim to know why the bracketing and quotation marks are required but it seems to work though I am still looking for alternative solutions so I can understand and learn.

    Incidentally using a 2003 version of Access the SetValue property macro worked just fine in hiding the field/control in form view.

    Was this answer helpful?

    0 comments No comments