Results 1 to 10 of 10
  1. #1
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78

    Error Form Load - ColumnOrder

    Hi,



    This is screenshot of my error with the code. When I click Stop to stop the macro, the datasheet view comes up how I wanted, any idea what's wrong? How can I get it to stop the error and continue with the datasheetview?



    Code:
    Private Sub Form_Load()
       'get access and edit mode status from main form
        Me.AllowEdits = bEditMode
       
        Me.AllowDeletions = False
        Me.AllowAdditions = False
      
     
        Me.[txtProjectNumber].ColumnOrder = 1
        Me.[txtQPNumber].ColumnOrder = 2
        Me.[txtWorkOrder].ColumnOrder = 3
        Me.[txtProject Title].ColumnOrder = 4
        Me.[cboEstimatingAction].ColumnOrder = 5
        Me.[cboEstimatePurpose].ColumnOrder = 6
        Me.[cboProjectDesignPhase].ColumnOrder = 7
        Me.[cboEstimateStatus].ColumnOrder = 8
        Me.[Directors Action Item list].ColumnOrder = 9
        Me.[dtRequestDate].ColumnOrder = 10
        Me.[dtRequestedCompletion].ColumnOrder = 11
        Me.[RequestByPerson].ColumnOrder = 12
        Me.[cboRequestByOrganization].ColumnOrder = 13
        Me.[isProgram].ColumnOrder = 14
        Me.[isRelease].ColumnOrder = 15
        Me.[txtProgramEstimate].ColumnOrder = 16
        Me.[bProjectDeliverables].ColumnOrder = 17
        Me.[bConstructabilityReview].ColumnOrder = 18
        Me.[cboRegion].ColumnOrder = 19
        Me.[txtScopeDescription].ColumnOrder = 20
        Me.[cboScopeCategory].ColumnOrder = 21
        Me.[cboBusinessUnit].ColumnOrder = 22
        Me.[cboWorkType].ColumnOrder = 23
        Me.[cboVoltageClass].ColumnOrder = 24
        Me.[txtPreviousEstimate].ColumnOrder = 25
        Me.[Priors].ColumnOrder = 26
        Me.[txtStatusNotes].ColumnOrder = 27
     
     
        Me.Requery
       
        Exit Sub
     
    End Sub
    Attached Thumbnails Attached Thumbnails image001.jpg  

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    brackets identify a [field] and it looks like you've wrapped your control names in them. If so, what can't be found is a field named "txtProjectNumber"
    Try removing from first line and see if you get past it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Why don't you just set the datasheet as you want?
    Seems a very long-winded way of doing it to me?
    I could understand if there was some conditions code in there, but otherwise?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    A datasheet will display columns in the order specified by the query - so perhaps rather than having code, specify it there instead.

    And agree with Micron - likely you need

    me.projectnumber.columnorder=1

    and there should be no need to requery

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I noticed the requery but forgot to ask why it's there. WGM, sometimes I wonder too but don't ask. My guess is that people mess around with the column order, and IIRC, if they save the form, the column order will stick.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    if they save the form, the column order will stick.
    don't disagree but they should not be given the opportunity to save the form (data yes, form no)

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    don't disagree but they should not be given the opportunity to save the form
    Can you actually totally prevent that? If I re-arrange the columns and just key Ctrl+S won't I save the column order? I'm thinking that is the case. Seems to work that way when tested.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    Well one way would be to provide users with a .accde - they can change the order manually, but the changes won't be saved

  9. #9
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You can also block keyboard shortcuts like Ctrl+S to prevent users making any design changes
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  10. #10
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    I removed that whole code and just let the Datasheet view pop up. What I was intending was for the user to select a record from the datasheet view and open another form to that record so they can make edits.




    Quote Originally Posted by Welshgasman View Post
    Why don't you just set the datasheet as you want?
    Seems a very long-winded way of doing it to me?
    I could understand if there was some conditions code in there, but otherwise?

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

Similar Threads

  1. Setting ColumnOrder on Split Form
    By Thunkd in forum Programming
    Replies: 1
    Last Post: 10-13-2017, 11:21 AM
  2. Can't load form : error 361
    By GeorgeJ in forum Programming
    Replies: 3
    Last Post: 12-08-2014, 02:58 AM
  3. On Load form error
    By Bosakie in forum Access
    Replies: 1
    Last Post: 10-09-2014, 07:27 AM
  4. Replies: 2
    Last Post: 09-16-2014, 06:17 AM
  5. ApplyFilter to form on Load error
    By rivereridanus in forum Access
    Replies: 1
    Last Post: 08-18-2011, 12:00 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