Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock / Unlock a data field in a subform 1

Status
Not open for further replies.

ericpsu32

Programmer
Sep 15, 2003
47
US
Good Afternoon,

I have a main form that contains header level information. On this same form, I have a subform that contains the details regarding the header. What I would like to do is if a condition exists, I would like to lock down the individual fields of the subform. How do I do this?

For example, my subform has two fields, call them "buy", and a "sell." If we have already paid a vendor for the item, I want to lock the buy field in my subform, but allow a user to continue to edit the "sell" rate until the record has been invoiced to our customer.

Because something can be paid to the vendor, but not invoiced and vice versa, I need to lock the individual fields in the subform.

I hope this makes sense. Any help would be appreciated.

Thanks!
Eric
 
Have a look at conditional formatting ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya ericpsu32 . . .

. . . a starting point using the [blue]On Current[/blue] event of the subform:
Code:
[blue]   If Me!Sell > 0 Then
      Me!Buy.Locked = True
   Else
      Me!Buy.Locked = False
   End If[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Thanks guys... here is some more information

I don't believe this is something that conditional formatting can handle, I will try the "on current" thing, but not sure what to do there...

Here is the code that I am working with. This is the on click property of a button on the main form.
Code:
 Dim sPaid As String
    Dim sInvd As String
    If DLookup("[InvDate]", "[tbl_Receivables]", "[Pkey] = '" & Me.pkey & "'") > "01/01/01" Then
        sInvd = "Y"
    Else
        sInvd = "N"
    End If
    If DLookup("[PaidDate]", "[tbl_Payables]", "[Pkey] = '" & Me.pkey & "'") > "01/01/99" Then
        sPaid = "Y"
    Else
        sPaid = "N"
    End If
    

    Me.frm_LTLShipmentDetail_HeaderInfo.Locked = False
    Me.frm_LTLShipmentDetail_LineDetails.Locked = False
    Me.frm_LTLShipmentDetail_RateDetails.Locked = False
        If sPaid = "N" Then
            frm_LTLShipmentDetail_RateDetails.Carrier.Locked = True

            me.frm_LTLShipmentDetail_RateDetails.Form.Carrier.Locked = True

            frm_LTLShipmentDetail_RateDetails.KDLRate.Locked = True
        Else
        End If
        If sInvd = "Y" Then
           frm_LTLShipmentDetail_RateDetails.BilalbleRate.Locked = True
        Else
        End If
        
    Me.frm_LTLShipmentDetail_CntDetail.Locked = False
    Me.InvoiceApproval.Enabled = True
    Me.InvoicedLabel.Visible = False
Else
    MsgBox "Password Incorrect"
End If
End Sub

What I am doing is looking to my receivables table to determine if the bill has been invoiced to our customer, then I look to the payables table to determine if the bill has been paid to the vendor. If the result is returned as a "N" I would like those fields to be unlocked on my subform. The subform in question is also a continuous form. Not sure if that makes a difference. Here is where my code fails, it can't find the fields in the subform to lock
Code:
frm_LTLShipmentDetail_RateDetails.Carrier.Locked = True
            frm_LTLShipmentDetail_RateDetails.KDLRate.Locked = True

Here is the error...
"Compile Error: Method or Data Member Not Found"


Thanks,
Eric
 
Aceman....

Awesome! The oncurrent property worked. I have been working in databases for a while (forum/self-taught), and have never used that property before.

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top