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

Change subform Column Widths with VBA?

My combo boxes have 3 columns: 0 is the ID, 1 is in English, and 2 is in French. Can I somehow send a command from a button on my main form to change the sub form Column Widths from 0";2";0" to, say, 0";0";2"? And how about the column header titles?

(My other option is to create 2 forms, but they specifically wanted to be able to change the language on the fly.)

Merci! (oops ... make that column(1) - Thanks!)

T.
0
TristanRyan
Asked:
TristanRyan
  • 5
  • 4
1 Solution
 
nico5038Commented:
Try like:

If Me.txtLanguage = 1 Then
   Me.cmbID.ColumnWidths = "0cm;0cm;2cm"
   Me.Refresh
Else
   Me.cmbID.ColumnWidths = "0cm;2cm;0cm"
   Me.Refresh
End If

Nic;o)
0
 
TristanRyanAuthor Commented:
Hmm. Perhaps I've done something wrong, or explained this incorrectly. That would work, I know, but the problem is that I can't find my combo boxes with my VB editor. My subform is based on a table and is displayed as a datasheet. When I'm in design mode, I can select the fields (say, cboAssignedTo), but I can't seem to find them in my VB editor. I tried me.subForm.Controls.Item(), me.cboAssignedTo, me.subForm.cboAssignedTo ...

Whassup?
0
 
nico5038Commented:
For that you need to add .form like:
me.subForm.Form.cboAssignedTo

Nic;o)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
TristanRyanAuthor Commented:
Well, it works! Thanks.

The only problem: I refresh AND requery, but the darn things stay in the same language on screen. When I click on the field, however, the drop down displays the correct column.

Should I go a different route, such as simply loading a new form?
0
 
nico5038Commented:
Try:
me.recordsource = me.recordsource

Looks silly but is 100% certain to requery the form :-)

Nic;o)
0
 
TristanRyanAuthor Commented:
Yes, looks silly, but even though it requeries, there's still no change. Perhaps this is just something that Access doesn't do. Hmm. Any suggestions?
0
 
nico5038Commented:
OK, next tricks:
1) Try a repaint
2) Assign the first value to the combo by using:
    me.subForm.Form.cboAssignedTo = me.subForm.Form.cboAssignedTo.Column(0,0)

Nic;o)
0
 
TristanRyanAuthor Commented:
Well, nope... but good idea. The solution: I just created a new form and did me.subform.sourceobject ... works like a charm.

0
 
nico5038Commented:
Glad it worked out, success with the application !

Nic;o)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

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