Results 1 to 9 of 9
  1. #1
    Helen's Avatar
    Helen is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28

    Datasheet as subform: retain or deny rearranging of columns.

    I have several forms with subforms that are data sheets.


    In all, I can rearrange the columns to where I want them for the current purpose - some days want one order, some another, as data sheets are very wide - drag columns interested in to the left.

    Problem is…. in some forms, the rearrangement is retained upon closing so I don't have to shift them again. In others, it resets the locations to where they were beforehand.

    I've compared the properties of the subform from the main form, and of the subform itself, using the ALL column, and everything appears to be identical but one retains the changed order, the other does not.

    I just can't find how to SET it to be one way or the other.

    Of course, the help within Access is next to useless.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Are you prompted to save the form upon exit at any time? Usually if you change the design you will be. If you are you can suppress that save message, save the form by default, and therefore save any changes you've made.

    Can you reliably duplicate the error. i.e. does it always happen on a specific form or forms and not on others?

  3. #3
    Helen's Avatar
    Helen is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28
    Thank you for replying!

    No, no prompt to save changes, just close.

    The rearranged columns are always retained on the forms it retains them, and never on those it doesn't. That's what prompted me to examine the properties of both, thinking that a property is set somehow, though I don't recall setting any properties in relation to it.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I can not duplicate your error.

    The easiest thing I can think to try is to recreate your forms/subforms that are not saving your changes (assuming that all the properties of each form and subform you currently have identical but behaving differently) and see if you can eliminate the behavior.

    The second thing to try is to check your relationships and make sure you're using a unique identifier as the link between your form and subform

    Lastly you can try to upload a test database that has some bogus data in it (access 2003 or prior please) and we can take a look

  5. #5
    Helen's Avatar
    Helen is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28
    Thanks for the idea. Recreating all the forms is not realistic, but it prompted what I've done to investigate.

    I remade one data sheet subform, so it had no coding behind it. It seemed that the problem was solved, UNTIL I added the coding. So… I commented out the code, and sequentially UNcommented line by line.
    At the stage below, rearranged columns (and changes to column width) ARE retained upon closing:

    Code:
    Private Sub Form_Open(Cancel As Integer)
    On Error GoTo Err_Form_Open
    
        Dim dtDefoltTD, dtDefoltNT As Date 'TD is TargetDate, NT is NextTarget
        Dim lngRecNum As Long
        Dim dtFirst, dtCurr As Date
    
        DoCmd.SetWarnings False
        'need to ensure weights are right due to calorie usage calculations
        DoCmd.OpenQuery "TargetsCalcWeightsQ"
    
        If DateAdd("d", 7, DMax("TDate", "TargetsEXT")) > Int(Now()) Then
            dtDefoltTD = DateAdd("d", 7, DMax("TDate", "TargetsEXT"))
        Else
           dtDefoltTD = Int(Now())
        End If
    
        dtDefoltNT = DateAdd("d", 7, dtDefoltTD)
    '    TDate.DefaultValue = "#" & Format(dtDefoltTD, "mm\/dd\/yyyy") & "#"
    '    NextTDate.DefaultValue = "#" & Format(dtDefoltNT, "mm\/dd\/yyyy") & "#"
    '    lngRecNum = DCount("Tdate", "TargetsEXT")
    
    '    'safety procedure to set every record's NextTDate to be equal to the next TDate.
    '    If lngRecNum > 1 Then
    '        dtFirst = Me.TDate
    '        DoCmd.GoToRecord acActiveDataObject, , acLast
    '        dtCurr = Me.TDate
    '
    '        Do Until dtCurr = dtFirst
    '            DoCmd.GoToRecord acActiveDataObject, , acPrevious
    '
    '            If Me.NextTDate <> dtCurr Then
    '                Me.AllowEdits = True
    '                Me.NextTDate = dtCurr
    '                DoCmd.Save acDefault
    '            End If
    '
    '            dtCurr = Me.TDate
    '        Loop
    
    '    End If
    
    Exit_Form_Open:
        DoCmd.SetWarnings True
        Exit Sub
    
    Err_Form_Open:
        MsgBox "Form_TargetsEXT subform, Form_Open, Error number: " & Err.Number & vbNewLine & Err.Description
        Resume Exit_Form_Open
        
    End Sub
    As soon as the next line (also given below) is UNcommented, any rearrangement or change to widths of columns is NOT retained upon closing.

    Code:
    '    TDate.DefaultValue = "#" & Format(dtDefoltTD, "mm\/dd\/yyyy") & "#"
    Any more great ideas?

  6. #6
    Access_Blaster is offline User
    Windows XP Access 2010 32bit
    Join Date
    May 2010
    Posts
    339
    Hi Helen,

    I would open a new database and Import everything into it, and see if the problem goes away.

    Richard

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Is there any way you can upload a sample database with garbage data in it to play around with (access 2003 or below please). If you remove the default value before you close the form it may help but that's the only thing I can think to try without something to work with.

  8. #8
    Helen's Avatar
    Helen is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28
    Quote Originally Posted by Access_Blaster View Post
    I would open a new database and Import everything into it, and see if the problem goes away.
    Thanks for the idea Richard. Tried it - no change, same thing happening.

  9. #9
    Helen's Avatar
    Helen is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28
    Investigations continue.
    It seems I CANNOT rearrange the columns or change widths when anything like the following appears in the code, even if it the line isn't executed - it just appears IN the code.

    Me.FieldName.Locked = True/False (either one has the same effect)
    Me.AllowEdits = True/False
    Me.AllowDeletions = True/False
    Me.RecordLocks = True/False
    FieldName.DefaultValue = ….

    Next I'm going to try to remove this code and add code to the OnDirty, OnDelete, & BeforeInsert events to achieve the same result without changing any properties - which seems to be the problem.

    Yup - solved by removing any of the above types of changes, addressed what I needed to get done using the above mentioned events.
    Last edited by Helen; 09-08-2011 at 12:53 AM.

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

Similar Threads

  1. Missing Columns in Datasheet View
    By mikel in forum Access
    Replies: 3
    Last Post: 01-02-2015, 01:57 PM
  2. Replies: 1
    Last Post: 05-23-2011, 07:11 AM
  3. Generate datasheet columns on the fly?
    By kman42 in forum Programming
    Replies: 0
    Last Post: 03-11-2011, 03:52 AM
  4. Subform, Totals, in Datasheet view
    By eww in forum Programming
    Replies: 1
    Last Post: 09-27-2010, 10:22 AM
  5. Replies: 6
    Last Post: 09-02-2010, 02:18 AM

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