enable/disable, show/hide checkbox help


E

EddWood

I have a Invoice form with a line items subform. On the subform I have a
checkbox for users to select which items of the order are to be shipped.

If I have the form open in 'Edit'mode users can select the check box to
indicate which items they wish to ship. However, as it is in edit mode, they
can also inadvertently select a checkbox for a row that does not have a
record and as such the application throws an error message as it has no
related record.

I therefore need a method that allows me to open the form in edit mode, but
does not have any blank records for the checkbox to be selected in error.

On the main form I have a field txtShippmentID that by default has no value,
and I require the user to create a shipment code in the first instance, so
my thought was to have something in the checkbox like:

Private Sub Form_Current()
If Me.txtShipmentID = "" Then
Me.Form!frmInvoiceLineItems.Check85.Visible = False
Else
Me.Form!frmInvoiceLineItems.Check85.Visible = True
End If
End Sub

But I think I am reference the subform incorrectly as it throws an error
saying it cannot find the field frmInvoiceLineItems?

But even if that was to work it would still be possible for a user to select
the checkbox for a blank row, so need a way I can only show the checkbox for
rows with a record.

Any suggestion most welcome
 
Ad

Advertisements

D

Dirk Goldgar

EddWood said:
I have a Invoice form with a line items subform. On the subform I have a
checkbox for users to select which items of the order are to be shipped.

If I have the form open in 'Edit'mode users can select the check box to
indicate which items they wish to ship. However, as it is in edit mode,
they can also inadvertently select a checkbox for a row that does not have
a record and as such the application throws an error message as it has no
related record.

I therefore need a method that allows me to open the form in edit mode,
but does not have any blank records for the checkbox to be selected in
error.

On the main form I have a field txtShippmentID that by default has no
value, and I require the user to create a shipment code in the first
instance, so my thought was to have something in the checkbox like:

Private Sub Form_Current()
If Me.txtShipmentID = "" Then
Me.Form!frmInvoiceLineItems.Check85.Visible = False
Else
Me.Form!frmInvoiceLineItems.Check85.Visible = True
End If
End Sub

But I think I am reference the subform incorrectly as it throws an error
saying it cannot find the field frmInvoiceLineItems?

But even if that was to work it would still be possible for a user to
select the checkbox for a blank row, so need a way I can only show the
checkbox for rows with a record.

Any suggestion most welcome

It sounds to me like all you have to do is set the Allow Additions property
of the subform's source-object form to No. You can do this in the form
design if the form will only ever be used as a subform in this mode. If the
same form should sometimes allow additions, you can use some event of the
parent form to set the property on the subform:

Me.frmInvoiceLineItems.Form.AllowAdditions = False
 
Ad

Advertisements

E

EddWood

Excellent thanks Dirk.


Dirk Goldgar said:
It sounds to me like all you have to do is set the Allow Additions
property of the subform's source-object form to No. You can do this in
the form design if the form will only ever be used as a subform in this
mode. If the same form should sometimes allow additions, you can use some
event of the parent form to set the property on the subform:

Me.frmInvoiceLineItems.Form.AllowAdditions = False


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

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