Can't get fields on a datasheet view form to get in the right order

I'm using the following code to get fields in a datasheet view form to appear in the right order.  But no matter what I do, txtGrossCWT won't appear in the 3rd column.  Am I doing something wrong?

    Const TWIPSTOINCHES = 1440
    Me!txtLoadID.ColumnWidth = TWIPSTOINCHES * 0.875
    Me!txtReceived.ColumnWidth = TWIPSTOINCHES * 1.25
    Me!txtGrossCWT.ColumnWidth = TWIPSTOINCHES * 1
    Me!txtTW.ColumnWidth = TWIPSTOINCHES * 0.75
    Me!txtFM.ColumnWidth = TWIPSTOINCHES * 0.75
    Me!txtCleanCWT.ColumnWidth = TWIPSTOINCHES * 1.125
    Me!txtMST.ColumnWidth = TWIPSTOINCHES * 0.75
    Me!txtShrink.ColumnWidth = TWIPSTOINCHES * 1.125
    Me!txtNetCWT.ColumnWidth = TWIPSTOINCHES * 1.125
    Me![txtSplits&Dmg].ColumnWidth = TWIPSTOINCHES * 1.125
    Me!txtPrice.ColumnWidth = TWIPSTOINCHES * 1.125
    Me!txtGrossCWT.ColumnWidth = TWIPSTOINCHES * 1.125
    Me!txtTotal.ColumnWidth = TWIPSTOINCHES * 1.125
    Me!txtLoadRecordID.ColumnWidth = TWIPSTOINCHES * 0

    If TWIPSTOINCHES * 1 > 0 Then
        Me!txtLoadID.ColumnHidden = False
        Me!txtReceived.ColumnHidden = False
        Me!txtGrossCWT.ColumnHidden = False
        Me!txtTW.ColumnHidden = False
        Me!txtFM.ColumnHidden = False
        Me!txtCleanCWT.ColumnHidden = False
        Me!txtMST.ColumnHidden = False
        Me!txtShrink.ColumnHidden = False
        Me!txtNetCWT.ColumnHidden = False
        Me![txtSplits&Dmg].ColumnHidden = False
        Me!txtPrice.ColumnHidden = False
        Me!txtGrossCWT.ColumnHidden = False
        Me!txtTotal.ColumnHidden = False
        Me!txtLoadRecordID.ColumnHidden = True
    End If

    Me.txtLoadID.ColumnOrder = 1
    Me.txtReceived.ColumnOrder = 2
    Me.txtGrossCWT.ColumnOrder = 3
    Me.txtTW.ColumnOrder = 4
    Me.txtFM.ColumnOrder = 5
    Me.txtCleanCWT.ColumnOrder = 6
    Me.txtMST.ColumnOrder = 7
    Me.txtShrink.ColumnOrder = 8
    Me.txtNetCWT.ColumnOrder = 9
    Me.[txtSplits&Dmg].ColumnOrder = 10
    Me.txtPrice.ColumnOrder = 11
    Me.txtGrossCWT.ColumnOrder = 12
    Me.txtTotal.ColumnOrder = 13
    Me.txtLoadRecordID.ColumnOrder = 14

Open in new window

SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Perhaps that textbox is missing the ColumnOrder property?

See how to set it here: ColumnOrder
SteveL13Author Commented:
It is there right under...  Me.txtReceived.ColumnOrder = 2

But I'll check out the link you sent.
NorieAnalyst Assistant Commented:
How/where are you using that code?
Active Protection takes the fight to cryptojacking

While there were several headline-grabbing ransomware attacks during in 2017, another big threat started appearing at the same time that didn’t get the same coverage – illicit cryptomining.

Gustav BrockCIOCommented:
I believe, that if you adjust the width manually (with the mouse), the property will be created automatically.
SteveL13Author Commented:
Norie...  in the onload event of the form.
Gustav... its not the width that is the issue.  Its the column order.
SteveL13Author Commented:
I changed the bottom part of the code to this and the 3rd column STILL won't appear in the right place.

    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail.Form!txtLoadID.ColumnOrder = 1
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtReceived.ColumnOrder = 2
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtGrossCWT.ColumnOrder = 3
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtTW.ColumnOrder = 4
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtFM.ColumnOrder = 5
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtCleanCWT.ColumnOrder = 6
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtMST.ColumnOrder = 7
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtShrink.ColumnOrder = 8
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtNetCWT.ColumnOrder = 9
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail![txtSplits&Dmg].ColumnOrder = 10
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtPrice.ColumnOrder = 11
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtGrossCWT.ColumnOrder = 12
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtTotal.ColumnOrder = 13
    Forms!frmAssemblySheetHeader.Form!subfrmAssemblySheetDetail!txtLoadRecordID.ColumnOrder = 14

Open in new window

SteveL13Author Commented:
I found my mistake.  I had the same column in the code twice.  Should have been more careful.
PatHartmanCommented:
You don't actually need code at all.  When the form is open in design view, press the Tab Order icon on the Design ribbon and choose auto Order.
SteveL13Author Commented:
Pat.  I know you are correct.  But I wanted to set the column widths also.  Maybe I didn't even need to mess with the VBA code for column orders. ??
PatHartmanCommented:
Column widths is a different problem.  The DS design interface is broken these days and it will not remember the widths you specified at design time reliably.  Every once in a while, I manage to get a form to remember the widths I want but sometimes I fail miserably and the multiple steps that worked last time, no longer work.  So, for now, you will need code.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gustav BrockCIOCommented:
I had the same column in the code twice.

Oh, missed that.
SteveL13Author Commented:
Good to know.  Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.