Columnwidth vba code

comicwizard

Registered User.
Local time
Today, 11:17
Joined
Mar 24, 2011
Messages
15
Hi i have a trigger on a form which once something is choosen goes to a look up table and should auto populate from that table. Since that table has multiple columns I am trying to get the code to choose from the second column. My code doesn't work. help.

Private Sub Forum_AfterUpdate()
If Me.Forum = "6" Then
Me.Forum_Other.Enabled = True
Me.Forum_Other = ""
ElseIf Me.Forum <> "6" Then
Me.Forum_Other.Enabled = False
Me.Forum_Other = Me.Forum.ColumnWidths = "0 in,1 in,0 in"
End If
End Sub
 
When you have

Private Sub Forum_AfterUpdate()

Is that a control that is named forum and is not supposed to be

Private Sub Form_AfterUpdate()

????

Just need some clarification because some of this code looks really strange.
 
Your code example doesn't really do much except attempt to manipulate the CoumnWidths property of (what I am assuming is) a combo or list box. Can you shed a little more light on what exactly it is you are trying to accomplish here?
 
It would help is you actually said what your procedure did when you run it rather than "doesn't work". It is really not clear what you have either.

The values in ColumnWidths property are separated by semicolons rather than commas.

Also note that regardless of which column you display in the combo or listbox the value property of that control will still be that of the Bound Column. You won't get the displayed amount unless you also refer to the column you want to retrieve.

In case you are trying to do something entirely different note that this is for the ColumnWidths property of a combo or listbox.

To change the ColumnWidth of columns in the datasheet view of a form like this you must specify each column individually and the value must be in Twips.

You can also use the ColumnHidden property to hide columns.

The column name are actually the controls on the form rather than the fields in the recordset. (If you made the form with the Wizard these will be the same so it won't matter.)

http://msdn.microsoft.com/en-us/library/aa224081(v=office.11).aspx

BTW Having tested if the value of the control is equal to some value the is no need to test that it is not equal to that value in the ElseIf since this is already established.
 

Users who are viewing this thread

Back
Top Bottom