X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Sub Form Help, Access 2013    
post Mar 6 2018, 10:38 AM

Posts: 173
Joined: 9-May 11
From: Columbus, GA USA

Hello forum!

In my application there is a form called the Build Sheet that itemizes all of the equipment and accessories requested by our customer. This equipment includes both serialized items and non-serialized items and there is a flag in the underlying table to indicate a serialized piece. The equipment list is a sub-form of the Build Sheet.

What I'm trying to do is to lock a field, called FillCount) on the subform for each piece of serialized equipment but not lock the field for any non-serialized piece. Using the On Open event I open a recordset consisting of all of the serialized items and then set the FillCount locked property to true. However, when the Build Sheet opens, if there is any serialized equipment then the code is locking all of the equipment instead of just the serialized equipment.

Here's the code I'm using (Note that [DI] is the flag indicating the equipment is serialized.):

Private Sub Form_Load()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL1 As String

Set dbs = CurrentDb()
pubTallyID = Me.Tally_ID

strSQL1 = "SELECT tblTallyRequest.Tally_ID, tblTallyRequest.DI " & _
    "From tblTallyRequest " & _
    "WHERE (((tblTallyRequest.Tally_ID) = GetTallyID()) And (tblTallyRequest.DI) = 'Y')"

Set rst = dbs.OpenRecordset(strSQL1, dbOpenDynaset)

Do While Not rst.EOF
    If rst![DI] = "Y" Then
        [Forms]![frmTallyPullSheet]![tblTallyRequest subform].[Form].[FillCount].Locked = True
    End If

Set dbs = Nothing
Set rst = Nothing

End Sub

Any suggestions on limiting the field locking to just the serialized pieces are greatly appreciated!

Go to the top of the page
post Mar 6 2018, 10:45 AM

Posts: 18,324
Joined: 29-March 05
From: Wisconsin


Remember - tables have fields, forms have controls.

I'd try this: In the control that is bound to the FillCount field, try using the GotFocus event along these lines:

If DI = "Y", set the .Locked property to True. If DI = "N", set the .Locked property to False. (This could be further simplified if the DI field was a boolean rather than text.)

You may need to tinker with this. I'm not sure if the user clicks on the FillCount for one record, then clicks on a different record's FillCount whether this will trigger for both clicks or not.

Hope this helps,

Go to the top of the page
post Mar 6 2018, 11:56 AM

Posts: 1,184
Joined: 26-January 06
From: .....the wiregrass (either you know or you don't)

Yep, Dennis has a good idea. Take a look at this to see how it works.

Although it might be done in the conditional formatting controls....think it is simple in the gotfocus event as Dennis said.
Attached File(s)
Attached File  ConditionalFieldLock.zip ( 35.07K )Number of downloads: 13
Go to the top of the page
post Mar 7 2018, 01:22 PM

Posts: 173
Joined: 9-May 11
From: Columbus, GA USA


Thank you so much for your advice. I added to my project and it is performing exactly as needed. I really appreciate the help.

Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    21st March 2019 - 04:47 AM