What have I done???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I had a few bits of code working nicely behing my subform frmProducts until I
tried to work with locking/disabling the fields in the form based on an
Option Group. Well, I finally got that working (the locking/disabling
options) ONCE and now my form has chucked a complete hissyfit!!! It's always
locked, no matter what option I choose in the Option Group.

So, I removed all the code behind this form, every single bit I could find
and copied them to a word document but the locking thing is still happening!
What can I do?
 
Open the form in design mode. Check the form's properties. Pick a control
you considered "locked/disabled". Check its properties.

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
You're probably right! I'm only using an If Then Else code!

Another question, I now have the AfterUpdate and OnCurrent events working
perfectly BUT the current event only fires when I change records in my
subform, not in my main form. That is, when I open the main form, the subform
displays fine, the AfterUpdate event works when I change the Option Group, if
I go to the next subform record and come back to the first one it is still
displaying correctly but if I go to the next main record and come back to the
first one the subform displays normally without the locking/disabling things
I've done. Is there another event that would be better for this? I thought On
Current would be the one that fires last.

Thanks (code below)

If Me.StatusBar.Value = 1 Then
Me.InvoiceNumber.Enabled = True
Me.OrderReference.Enabled = True
Me.Quantity.Enabled = True
Me.Code.Enabled = True
Me.Item.Enabled = True
Me.Problem.Enabled = True
Me.LongCode.Enabled = True
Me.SellPrice.Enabled = True
Me.CostPrice.Enabled = True
Me.Action.Enabled = True
Me.Supplier.Enabled = True
Me.HandlingFee.Enabled = True
Me.HandlingFeeAmount.Enabled = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementReference.Enabled = True
Me.DiscountOffered.Enabled = True
Me.Discount.Enabled = True
Me.DiscountAmount.Enabled = True
Me.SubTotal.Enabled = True
Me.Collect.Enabled = True
Me.cmdReturn.Enabled = True
Me.cmdCollect.Enabled = True
ElseIf Me.StatusBar.Value = 2 Then
Me.InvoiceNumber.Enabled = True
Me.OrderReference.Enabled = True
Me.Quantity.Enabled = True
Me.Code.Enabled = True
Me.Item.Enabled = True
Me.Problem.Enabled = True
Me.LongCode.Enabled = True
Me.SellPrice.Enabled = True
Me.CostPrice.Enabled = True
Me.Action.Enabled = True
Me.Supplier.Enabled = True
Me.HandlingFee.Enabled = True
Me.HandlingFeeAmount.Enabled = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementReference.Enabled = True
Me.DiscountOffered.Enabled = True
Me.Discount.Enabled = True
Me.DiscountAmount.Enabled = True
Me.SubTotal.Enabled = True
Me.Collect.Enabled = True
Me.cmdReturn.Enabled = True
Me.cmdCollect.Enabled = True
ElseIf Me.StatusBar.Value = 3 Then
Me.InvoiceNumber.Enabled = True
Me.OrderReference.Enabled = True
Me.Quantity.Enabled = True
Me.Code.Enabled = True
Me.Item.Enabled = True
Me.Problem.Enabled = True
Me.LongCode.Enabled = True
Me.SellPrice.Enabled = True
Me.CostPrice.Enabled = True
Me.Action.Enabled = True
Me.Supplier.Enabled = True
Me.HandlingFee.Enabled = True
Me.HandlingFeeAmount.Enabled = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementReference.Enabled = True
Me.DiscountOffered.Enabled = True
Me.Discount.Enabled = True
Me.DiscountAmount.Enabled = True
Me.SubTotal.Enabled = True
Me.Collect.Enabled = True
Me.cmdReturn.Enabled = True
Me.cmdCollect.Enabled = True
ElseIf Me.StatusBar.Value = 4 Then
Me.InvoiceNumber.Enabled = True
Me.OrderReference.Enabled = True
Me.Quantity.Enabled = True
Me.Code.Enabled = True
Me.Item.Enabled = True
Me.Problem.Enabled = True
Me.LongCode.Enabled = True
Me.SellPrice.Enabled = True
Me.CostPrice.Enabled = True
Me.Action.Enabled = True
Me.Supplier.Enabled = True
Me.HandlingFee.Enabled = True
Me.HandlingFeeAmount.Enabled = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementReference.Enabled = True
Me.DiscountOffered.Enabled = True
Me.Discount.Enabled = True
Me.DiscountAmount.Enabled = True
Me.SubTotal.Enabled = True
Me.Collect.Enabled = True
Me.cmdReturn.Enabled = True
Me.cmdCollect.Enabled = True
ElseIf Me.StatusBar.Value = 5 Then
Me.InvoiceNumber.Enabled = True
Me.OrderReference.Enabled = True
Me.Quantity.Enabled = True
Me.Code.Enabled = True
Me.Item.Enabled = True
Me.Problem.Enabled = True
Me.LongCode.Enabled = True
Me.SellPrice.Enabled = True
Me.CostPrice.Enabled = True
Me.Action.Enabled = True
Me.Supplier.Enabled = True
Me.HandlingFee.Enabled = True
Me.HandlingFeeAmount.Enabled = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementReference.Enabled = True
Me.DiscountOffered.Enabled = True
Me.Discount.Enabled = True
Me.DiscountAmount.Enabled = True
Me.SubTotal.Enabled = True
Me.Collect.Enabled = True
Me.cmdReturn.Enabled = True
Me.cmdCollect.Enabled = True
ElseIf Me.StatusBar.Value = 6 Then
Me.InvoiceNumber.Enabled = True
Me.InvoiceNumber.Locked = True
Me.OrderReference.Enabled = True
Me.OrderReference.Locked = True
Me.Quantity.Enabled = True
Me.Quantity.Locked = True
Me.Code.Enabled = True
Me.Code.Locked = True
Me.Item.Enabled = True
Me.Item.Locked = True
Me.Problem.Enabled = True
Me.Problem.Locked = True
Me.LongCode.Enabled = True
Me.LongCode.Locked = True
Me.SellPrice.Enabled = True
Me.SellPrice.Locked = True
Me.CostPrice.Enabled = True
Me.CostPrice.Locked = True
Me.Action.Enabled = True
Me.Action.Locked = True
Me.Supplier.Enabled = True
Me.Supplier.Locked = True
Me.HandlingFee.Enabled = True
Me.HandlingFee.Locked = True
Me.HandlingFeeAmount.Enabled = True
Me.HandlingFeeAmount.Locked = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementOrder.Locked = True
Me.ReplacementReference.Enabled = True
Me.ReplacementReference.Locked = True
Me.DiscountOffered.Enabled = True
Me.DiscountOffered.Locked = True
Me.Discount.Enabled = True
Me.Discount.Locked = True
Me.DiscountAmount.Enabled = True
Me.DiscountAmount.Locked = True
Me.SubTotal.Enabled = True
Me.SubTotal.Locked = True
Me.Collect.Enabled = True
Me.Collect.Locked = True
ElseIf Me.StatusBar.Value = 7 Then
Me.InvoiceNumber.Enabled = True
Me.InvoiceNumber.Locked = True
Me.OrderReference.Enabled = True
Me.OrderReference.Locked = True
Me.Quantity.Enabled = True
Me.Quantity.Locked = True
Me.Code.Enabled = True
Me.Code.Locked = True
Me.Item.Enabled = True
Me.Item.Locked = True
Me.Problem.Enabled = True
Me.Problem.Locked = True
Me.LongCode.Enabled = True
Me.LongCode.Locked = True
Me.SellPrice.Enabled = True
Me.SellPrice.Locked = True
Me.CostPrice.Enabled = True
Me.CostPrice.Locked = True
Me.Action.Enabled = True
Me.Action.Locked = True
Me.Supplier.Enabled = True
Me.Supplier.Locked = True
Me.HandlingFee.Enabled = True
Me.HandlingFee.Locked = True
Me.HandlingFeeAmount.Enabled = True
Me.HandlingFeeAmount.Locked = True
Me.ReplacementOrder.Enabled = True
Me.ReplacementOrder.Locked = True
Me.ReplacementReference.Enabled = True
Me.ReplacementReference.Locked = True
Me.DiscountOffered.Enabled = True
Me.DiscountOffered.Locked = True
Me.Discount.Enabled = True
Me.Discount.Locked = True
Me.DiscountAmount.Enabled = True
Me.DiscountAmount.Locked = True
Me.SubTotal.Enabled = True
Me.SubTotal.Locked = True
Me.Collect.Enabled = True
Me.Collect.Locked = True
ElseIf Me.StatusBar.Value = 8 Then
Me.InvoiceNumber.Enabled = False
Me.OrderReference.Enabled = False
Me.Quantity.Enabled = False
Me.Code.Enabled = False
Me.Item.Enabled = False
Me.Problem.Enabled = False
Me.LongCode.Enabled = False
Me.SellPrice.Enabled = False
Me.CostPrice.Enabled = False
Me.Action.Enabled = False
Me.Supplier.Enabled = False
Me.HandlingFee.Enabled = False
Me.HandlingFeeAmount.Enabled = False
Me.ReplacementOrder.Enabled = False
Me.ReplacementReference.Enabled = False
Me.DiscountOffered.Enabled = False
Me.Discount.Enabled = False
Me.DiscountAmount.Enabled = False
Me.SubTotal.Enabled = False
Me.Collect.Enabled = False
Me.cmdReturn.Enabled = False
Me.cmdCollect.Enabled = False
End If
 
You probably saved the form while it was open and some of
the settings had been made. This might be a reflex thing to
do if you are modifying some of your code without switching
the form back to design view. However, this problem is only
one of the most minor consequences of modifying a form's
design while in form view. Try to get into the habit of
always switching back to design view before making design or
code changes to a form or report.

If you have some status bar values that you want the same
settings for all the controls, then you may find it more
convenient to use Select Case instead of If, ElseIf. For
example:
Select Case Me.StatusBar
Case 1,2,3,4,5
Me.InvoiceNumber.Enabled = True
. . .
Case 6,7
Me.InvoiceNumber.Enabled = True
Me.InvoiceNumber.Locked = True
. . .
Case 8
Me.InvoiceNumber.Enabled = False
. . .
End Select

I notice that your code is highly repetitive, but not quite
the same actions in all the ElseIf blocks. The fact that
some controls Locked property is not set to either True or
False implies that they will be locked however it was set by
a previous record, surely not a desired effect!? Normally,
you should set both properties in every block.
 

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

Back
Top