Solved

Hide  / collapse columns in Form as needed

Posted on 2013-01-07
8
979 Views
Last Modified: 2013-01-07
Hi

I am using Access 2010. This question is about a continuous form. The underlying table accepts movement of inventory from source to destination.

When the user opens the form, he/she will use an unbound combobox to choose whether the data entry will reflect items sold or items transferred. If the user chooses "transfer", then there is no need to enter information in some fields... ie [price], [discount] etc.

In such cases (user has chosen "transfer"), I would like the unwanted fields to disappear. That is easy enough. I also want to collapse the empty space so that the resultant form does not look like a patchwork quilt. It would be great if I could put these fields on the outermost right of the form, but this is not possible. I would like to emulate the way that Excel does it when you hide a column.

At this time, the best that I can come up with is to make them invisible, set their width to one pixel and move all the other columns next to the invisible column. I haven't tried this yet. It seems like a complex way to solve a simple problem.

I really would like to perform both tasks in one form. Is there a better way?
0
Comment
Question by:peispud
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 84
ID: 38750446
Is your continuous form in Datasheet view? If so, you can use the ColumnHidden method:

Me.Text0.ColumnHidden = True
0
 

Author Comment

by:peispud
ID: 38750466
Nope..    Form is not in Datasheet view.


I have set the view to continuous form.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38750614
Since you are in a continuous form, the problem will be that some records may say "Transfer" and others may reflect another value, so depending on what record you are on, you may want to suppress certain values while displaying those same values in the other records.

It is not possible to hide values in one record, but not in another in a continuous form.  It is one or all.
0
 

Author Comment

by:peispud
ID: 38751321
There will be no confusion in the record

Each record will have a field which will say "Transfer" or "Sale".

If the current record represents a transfer,  then  fields like [Price} and [Discount} do not apply.  

The user will be entering this information in batches (~200).  

I'm starting to think that the only way is to create two forms.
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 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38751376
Have you tried the method described above:

1. Open the form in design mode
2. Select the [Price] and [Discount] controls
3. Click the Conditional Formatting button on the ribbon or menu option (depending on version).
4. Set the Condition1 combo box to "Expression Is", then set the expression like:

[FieldName] = "Transfer"

5.  Then change the foreground and background colors so that they are the same as the detail section background color (or as close as you can get).
6.  Click OK
7.  Then select the [Price] control, select the "GotFocus" event from the Properties -> Event tab, and select [Event Procedure], and then go to that event in the VBA window.
8.  In the GotFocus event, add some code to change the focus from that control to another control, one that can change.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38751553
Hiding Columns seems like something that should be simple, in fact it can be quite complex:
Record the column name and width
Detect Reduce the field width to zero
Move the remaining fields over (by the same amount that the field was reduced) to eliminate the blank space
...This is all for only one filed, doing this for multiple, disparate fields, can get hairy...

What about just creating a separate form just for these situations...

You can see this sample I made a while back to dynamically hide/show controls/Fields in a Report.
http://filedb.experts-exchange.com/incoming/2009/11_w46/202728/Access--Basic-SampleSelectHideSh.mdb

JeffCoachman
0
 

Author Closing Comment

by:peispud
ID: 38752681
Thank you again sir.

I had considered this approach but wanted to make sure that I didn't miss a whole new angle to the problem.

I will likely create a second form.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38752830
Thanks,

As fyed will also tell you, we are big proponents of not only trying to let you see the many ways of doing something, but to also suggest alternatives.

JeffCoachman
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Password on a button in Access 2013 7 35
vba DCount with 2 criteria 3 34
Change AD password via MS Access DB 2 17
MS Access Tables Linking 6 40
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

19 Experts available now in Live!

Get 1:1 Help Now