Solved

Change subform Column Widths with VBA?

Posted on 2004-04-17
9
610 Views
Last Modified: 2006-11-17
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
Comment
Question by:TristanRyan
  • 5
  • 4
9 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 100 total points
ID: 10850170
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
 
LVL 1

Author Comment

by:TristanRyan
ID: 10850997
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
 
LVL 54

Expert Comment

by:nico5038
ID: 10851064
For that you need to add .form like:
me.subForm.Form.cboAssignedTo

Nic;o)
0
 
LVL 1

Author Comment

by:TristanRyan
ID: 10854218
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 54

Expert Comment

by:nico5038
ID: 10854277
Try:
me.recordsource = me.recordsource

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

Nic;o)
0
 
LVL 1

Author Comment

by:TristanRyan
ID: 10855214
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
 
LVL 54

Expert Comment

by:nico5038
ID: 10855233
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
 
LVL 1

Author Comment

by:TristanRyan
ID: 10855611
Well, nope... but good idea. The solution: I just created a new form and did me.subform.sourceobject ... works like a charm.

0
 
LVL 54

Expert Comment

by:nico5038
ID: 10855631
Glad it worked out, success with the application !

Nic;o)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bind Combobox 4 29
Reset Active Directory Password via MS Access 9 52
MS accesss using VBA to change a default value 5 27
Query design issue 2 22
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now