• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 25
  • 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"
Else
    Me!cboVariety.ColumnWidths = "0;1;0;0"
End If

 

 

End Sub
0
maxdbase
Asked:
maxdbase
1 Solution
 
PatHartmanCommented:
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;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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