Results 1 to 9 of 9
  1. #1
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27

    Maintaining one field (not allowing it to be changed) but keeping it the same

    we have a table it looks like this



    I want to ensure that the user cannot change the Hull no. Contract no
    How is this possible in a form, using DATASHEET VIEW

    ALSO IN ADDITION
    I want the hull no to be repeated and the contract no.
    But not allow any changes to those two fields.



    HULL NO. CONTR NO. DWG NO. REV SECT NO. CONTR ITEM NO. TAG/SYMBOL/SYSTEM NO. DWG ITEM NO. TOTAL QTY U/M DESCRIPTION MATL/SPEC MFG/MODEL NO. ELEC FINISH REMARKS CATALOG NO. UNIT WT (LBS)


    0002 12-4823 635-02 - 635 004-00 4 4511 SF Thermal Insulation, 1" FG UnFaced, 3/4 lbs/cu. ft Blanket Fiberglass 164.109 (INSUL)
    0002 12-4823 635-02 - 635 005-00 5 1961 SF Thermal Insulation, 2" FG, Mylar Faced, 2.9 lbs/cu. Ft Fiberglass 164.109 (INSUL) 164.112 (FACING)

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As to the first question:
    Code:
    Private Sub Form_Current()
     If Nz(Me.[Hull no], "") <> "" Then
      [Hull no].Locked = True
     Else
      [Hull no].Locked = False
     End If
     
     If Nz(Me.[Contract No], "") <> "" Then
      [Contract No].Locked = True
     Else
      [Contract No].Locked = False
     End If
    End Sub

    I prefer the above because it makes it clearer what is going on, but this works, as well:
    Code:
    Private Sub Form_Current()
     
     [Hull no].Locked = (Nz(Me.[Hull no], "") <> "")
      
     [Contract No].Locked = (Nz(Me.[Contract No], "") <> "")
     
    End Sub


    You'll have to replace [Hull no] and [Contract No] with your exact names, of course.

    I'm afraid I don't quite understand your second question; could you give a little more detail as to what you mean by

    I want the hull no to be repeated and the contract no.
    But not allow any changes to those two fields.
    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    We will have multiple rows of the same hull and contract no.
    But the Descriptions, section no, materials, will change.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by finsmith View Post
    We will have multiple rows of the same hull and contract no.
    But the Descriptions, section no, materials, will change.
    Sorry, I still don't understand the problem. As long as the numbers aren't defined as 'Autonumbers' and Duplicates are allowed in your Table Def you should have no problem. Locking the Field, where it has already been populated, won't effect the ability to use the same numbers in other Records.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    I have to look up locking a field. did not know that it existed. Thank you

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by finsmith View Post

    ...I have to look up locking a field...
    'Locking' means that you can tab/click into a Control, such as a Textbox, but you cannot physically Enter/Edit/Delete data that is contained in that Control. Notice that I said 'physically;' while you cannot do these things using the keyboard or by pasting data into the Control, you can, however, do these things through the use of VBA code.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    Hello Again. Linq.
    I was able to lock the field in the field properties. Thank you.
    The objective was to get the field to populate throughout the datasheet table. Meaning that

    Field 1 Field 2 Field 3 Field 4
    1111 Contract Apples Carrots
    1111 Contract Soups Celery

    Getting and Maintaining Field 1 & Field 2 to stay the same throughout the table.

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If you're saying that you want Field 1 & Field 2 to remain the same, as you add consecutive Records through your Form, you can use the AfterUpdate event of each Control to set its DefaultValue. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record.

    Code:
    Private Sub YourControlName_AfterUpdate()
       Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
    End Sub

    which is valid for Text, Number and Date Datatypes.

    You’ll need to do this for each Control that you want to ‘carry forward.’

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  9. #9
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    the second part. me.yourcontrolanme.value.
    it is coming from another table. so can I do
    contract_tbl.hullno.value

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

Similar Threads

  1. Keeping field contents if a source changes
    By gafferuk in forum Access
    Replies: 3
    Last Post: 12-28-2011, 05:39 AM
  2. keeping current entry in field until changed
    By Chazcoral in forum Forms
    Replies: 16
    Last Post: 09-09-2010, 12:01 PM
  3. Memo Field Not Keeping Data
    By maintt in forum Forms
    Replies: 1
    Last Post: 08-12-2010, 05:55 PM
  4. Replies: 13
    Last Post: 11-25-2009, 03:10 PM
  5. Replies: 7
    Last Post: 05-29-2009, 04:27 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