• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 17
  • Last Modified:

Microsoft Access 2010 - set dynamic columnwidth based on data

I have a sub report in a report.  I want to change the column widths property based on blank vs populated in columns from right to left

This code does not seem to update the report, how can I make this work

Private Sub Detail_Paint()
If Trim(Me!cboVariety.Column(3)) <> "" Then
    Me!cboVariety.ColumnWidths = "0;0;0;1"
ElseIf Trim(Me!cboVariety.Column(2)) <> "" Then
    Me!cboVariety.ColumnWidths = "0;0;1;0"
    Me!cboVariety.ColumnWidths = "0;1;0;0"
End If



End Sub
1 Solution
Are you really trying to change  the control property on every record?  You need to rethink this process.

A possible solution is to change the Recordsource query to join to the lookup table and select the two fields.  Use an IIf() to choose which column to display

Select ...., IIf(Len(fieldA) = 0, fieldB, fieldA) As yourresultfield
From YourTable Left Join YourLookupTable On YourTable.somefield = YourLookupTable.somefield;

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now