473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Adding a new column to a subform

167 100+
I have a form which includes a subform. I have modified the design of the subform to include a new column called 'Diff'. When I open up the form and the subform is loaded, the new column I added is not in the location that I put it when I added it in design mode to the subform. Is there some ordering for columns that I am missing?
May 30 '07 #1
7 9646
puppydogbuddy
1,923 Expert 1GB
I have a form which includes a subform. I have modified the design of the subform to include a new column called 'Diff'. When I open up the form and the subform is loaded, the new column I added is not in the location that I put it when I added it in design mode to the subform. Is there some ordering for columns that I am missing?
Yes. When you add fields to a form or subform, Access defaults the tab order to be the order in which the fields were added, except when the order has been changed by using the change tab order dialog box. To change tab order:
1. Open the form in Design View.
2. Click on View on the Menu Bar and select Tab Order. The Tab
Order dialog box will appear.
3. Click on the Auto Order button if you want to reorder the entry
sequence going left to right across each row of fields, then top to
bottom, and/or
4. Drag any control to a new location by clicking the button at the left
of its name and dropping it where ever you want it to be in the
sequence.
5. Click on OK to implement the changes you made.
May 31 '07 #2
ncsthbell
167 100+
I have already tried this, it changes the order that you can tab through the columns on the (sub)form but not the order the columns are displayed on the (sub)form.
Jun 1 '07 #3
puppydogbuddy
1,923 Expert 1GB
I have already tried this, it changes the order that you can tab through the columns on the (sub)form but not the order the columns are displayed on the (sub)form.
Right you are! The only thing I can think of is that Display Order of columns in the subform is being impacted by the display order of the columns in the subform's underlying query. Compare the order of the columns when the query is run by itself vs your subform.
Jun 1 '07 #4
ncsthbell
167 100+
The data source for my subform is a Table, not a query. The only way I can think to do this is delete the subform and rebuild which is a lot of work and there is a lot of code behind the form..... PLUS, I have many more to do the same thing to! Any other ideas?
Jun 1 '07 #5
ncsthbell
167 100+
I also tried ordering the columns in the table to match my display of columns on the subform and that did not work either.
Jun 1 '07 #6
puppydogbuddy
1,923 Expert 1GB
I also tried ordering the columns in the table to match my display of columns on the subform and that did not work either.
I will look into it further and get back to you, but here is what I have found so far about re-ordering the view of columns :

To re-order columns, select a column by clicking in the Column Selector, the column will highlight, click and hold down the mouse button within the column selector, and drag the small rectangle which appears, dropping it into the column to the left of which you wish the selected column to appear.
To freeze columns, so that they always display, select them using the column selector and choose Freeze Columns from the Format menu.
Jun 1 '07 #7
puppydogbuddy
1,923 Expert 1GB
Ok, I found a good source of information for you in the MS Access on-line help. If you go to the Help Index and type in View Order and hit enter, you will get a list of help topics....the relevant ones you need to look at are ColumnOrder Property and Changing the layout of a subform.

In summary these properties only apply to the datasheet view only and can not be set or changed in design view or in Form View. You can use VBA to change the datasheet view (see below), but not Form view. However, if you've ever used the form wizard, the wizard will create the form base on the order of the columns in the underlying table datasheet view at the time the the form or subform was created.

I think worse case scenario, you can programatically change the column order of the datasheet through VBA. If you are using a datasheet view, you will be ok at this point. If you are using a form view, you have the additional step of using the form wizard to recreate your subform in the desired view order If you use AutoFormat to standardize your settings (discussed below), it should be easier..

Standardise your Forms and Reports with AutoFormat

Design a form/report that uses your standard fonts, colors, borders, background settings, and control properties.

In Design view, from the Menubar select Format, AutoFormat... , and then in the AutoFormat Dialog click Customize...

Under Customize options in the Customize AutoFormat dialog box, select Create A New AutoFormat Based On The Form/Report and click OK. Enter a name for the standard style in the New Style Name dialog, and click OK. Click Close.

To apply the custom format to a form/report, open the form/report in Design view, select Format, AutoFormat... , then select the new format from the Form/Report AutoFormats list, and click OK.

VBA Code to Change ColumnOrder Property Example

The following example displays the ProductName and QuantityPerUnit fields in the first two columns in Datasheet view of the Products form.

Forms!Products!ProductName.ColumnOrder = 1
Forms!Products!QuantityPerUnit.ColumnOrder = 2The next example displays the ProductName and QuantityPerUnit fields in the first two columns of the Products table in Datasheet view. To set the ColumnOrder property, the example uses the SetFieldProperty procedure. If this procedure is run while the table is open, changes will not be displayed until is closed and reopened.
Expand|Select|Wrap|Line Numbers
  1. Dim dbs As Database, tdfProducts As TableDef
  2. Set dbs = CurrentDb
  3. Set tdfProducts = dbs!Products
  4. SetFieldProperty tdfProducts!ProductName, "ColumnOrder", dbLong, 2
  5. SetFieldProperty tdfProducts!QuantityPerUnit, "ColumnOrder", dbLong, 3
  6.  
  7. Sub SetFieldProperty(fldField As Field, strPropertyName As String, _
  8.         intPropertyType As Integer, varPropertyValue As Variant)
  9.     ' Set field property without producing nonrecoverable run-time error.
  10.     Const conErrPropertyNotFound = 3270
  11.     Dim prpProperty As Property
  12.     On Error Resume Next                ' Don't trap errors.
  13.     fldField.Properties(strPropertyName) = varPropertyValue
  14.     If Err <> 0 Then                    ' Error occurred when value set.
  15.         If Err <> conErrPropertyNotFound Then
  16.             On Error GoTo 0
  17.             MsgBox "Couldn't set property '" & strPropertyName _
  18.                 & "' on field '" & fldField.name & "'", 48, "SetFieldProperty"
  19.         Else
  20.             On Error GoTo 0
  21.             Set prpProperty = fldField.CreateProperty(strPropertyName, _
  22.                 intPropertyType, varPropertyValue)
  23.             fldField.Properties.Append prpProperty
  24.         End If
  25.     End If
  26. End Sub
  27.  
Jun 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: martim07 | last post by:
How do I have a textbox on a subform automatically fill in with a value after I select an item from a combo box on a form (e.g., select a product name in a combo box and have the subform populate...
3
by: A Clark | last post by:
I have a subform that displays a datasheet. There are a couple of different queries that can be displayed in the datasheet. The queries are available in a combo box on the main form. The problem...
1
by: angel duran | last post by:
Hi... i'm trying to accomplish this and i will be using some pictures so you can easily follow me along. I have this form <link>http://img30.exs.cx/my.php?loc=img30&image=4214.jpg</link> and in...
1
by: Thomas Zimmermann | last post by:
I have a form with a subform in datasheet view. Now, I want to trigger a procedure (P1) each time the user selects an entire column (by clicking in the heading) in the subform. The procedure (P1) I...
3
by: john | last post by:
In my form (table A) I have subform (table B (only 2 fieds: ID and App_name) where table A -Table B are linked 1XM. To be able to add a record in the subform I want to use a lookup form since the...
1
by: Kev | last post by:
Hi, I am trying to total a column (Shift1) in a subform (continous forms) from the after update event of the (Shift1) column control within the subform. This column stores shift codes, I want to...
1
by: christianlott1 | last post by:
I want to provide users with an interface to create a custom merge (all in Access, not Word). User will put in a set of brackets ("<>") in a memo field and when they click the merge button it will...
2
by: ncsthbell | last post by:
I have a form with a subform and I am trying to change the size of a column on the subform. I am following the instructions in the access help 'Change the layout of a subform in Datasheet view" to...
1
by: ncsthbell | last post by:
Here is the scenario. I have a form-"formA", I created another form-"FormB" which will be placed on FormA . I go to FormA in desgn view and use the button for "create subform" to bring in "FormB"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.