Results 1 to 3 of 3
  1. #1
    schof99 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2015
    Posts
    5

    Only Allow Field Edit When Blank And With Specific Content?

    Hi there,



    I have lurked around this site for some time now and always been able to find answers in previously asked questions. However, I can't seem to figure this one out.

    Apologies if this a little long winded but I want to make sure I give you enough information so that you understand my problem.

    I have two tables:

    tblProviders which contains fields - AlphaID (primary key), LastName, FirstName, Specialty.
    tblTransfers which contains fields - AccNumber (primary key), TDate, TDestination, Service, AlphaID, Reason

    tblTransfers is linked to a .txt file that is updated daily by the software we use at work and the records are appended to the table.

    Sometimes the AlphaID is not available in the .txt file as it has not been documented in the other software we use. I have a form that users will open to fill in the Reason field and, when needed, the AlphaID.

    I need the AlphaID field to be locked down so that a.) it can only be completed when it is empty and b.) it can only accept an AlphaID from tblProviders.

    So far I have:
    Private Sub AlphaID_GotFocus()

    If Nz(Me.AlphaID, "") <> "" Then
    AlphaID.Locked = True
    Else
    AlphaID.Locked = False
    End If

    End Sub

    This works great for only allowing the field to be edited if it is blank.

    I also have a combobox that can be used to select a provider and the following code to establish the AlphaID for that provider:

    Private Sub cboProviderLookup_AfterUpdate()

    Me.AlphaID.Value = Me.cboProviderLookup.Column(0)

    End Sub
    So, I can do each of the tasks seperately. What I am struggling with is how to combine these two things so that AlphaID can only be edited when the record is blank and can only accept an AlphaID from tblProviders.

    I would greatly appreciate any pointers you can offer, thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Should probably use Conditional Formatting to enable/disable the control.

    Use a combobox that lists the values from tblProviders and set LimitToList property as Yes.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Another option would be to create a query which only selects records from tblTransfers where Alpha_ID has no value: AlphaID is Null

    and use the query as a recordsource for an update form. To assign an ID, you can use a combo box bound to the AlphaID table field to avoid the VBA as you have it above.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 01-03-2015, 07:18 PM
  2. How to get entry of a specific Edit-Box ?
    By fluppe in forum Access
    Replies: 3
    Last Post: 07-15-2014, 09:18 AM
  3. VBA sql to edit specific information
    By Ruegen in forum Programming
    Replies: 1
    Last Post: 11-13-2013, 07:36 PM
  4. Replies: 2
    Last Post: 02-22-2012, 02:36 AM
  5. update field with specific content
    By luxeon in forum Queries
    Replies: 2
    Last Post: 01-24-2011, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums