Subform data sheet and form view

Hi all

I have a Subform that is viewed sometimes in data sheet and sometimes in form view. When switching is there any way of hiding (programmatically) some of the columns in data sheet view.

These controls would be hidden in form view and hold information that is not necessary to the user
Derek BrownMDAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
You can use the ColumnHidden property

EG:

Me.YourTextBoxName.ColumnHidden = True ' False

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
see image
Capture1.gif
0
Derek BrownMDAuthor Commented:
I tried this in the subform's onchange event and in the main form's on change event

Me.QCW1.ColumnHidden = True
Me.QCW2.ColumnHidden = True
Me.QCW3.ColumnHidden = True
Me.QCW4.ColumnHidden = True
Me.QCW5.ColumnHidden = True
Me.QCW6.ColumnHidden = True

and various versions of the following again in both on change events. Details being the name of the subform

[Details].Form![QCW1].ColumnHidden = True
[Details].Form![QCW2].ColumnHidden = True
[Details].Form![QCW3].ColumnHidden = True
[Details].Form![QCW4].ColumnHidden = True
[Details].Form![QCW5].ColumnHidden = True

I must be doing something wrong?
[Details].Form![QCW6].ColumnHidden = True


0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Forms don't have a On Change event, so I'm not quite following ....

mx
0
Derek BrownMDAuthor Commented:
Sorry I mean on view change event

Capture.JPG
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Umm ... that Event is not what it implies.  It deals with Pivot Table stuff (I think) ... as do all the events in that immediate area.

So, on your main form ... you will need a button, that toggles between the two views

DoCmd.RunCommand acCmdDatasheetView

 DoCmd.RunCommand acCmdFormView

And probably toggle the Button Caption property ... to correspond with view switching.

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
And you will probably need to Set Focus to the Subform Control

Me.YourSubFormControlName.SetFocus

prior to executing the DoCmd line.  And of course, the code to hide/unhide the columns.

mx
0
Derek BrownMDAuthor Commented:
I have noticed that column hidden does not seem to apply to a bound control. Could this be the problem? Applies to list
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Column Hidden only applies IN datasheet view ... and you must refer to the Name of the Control.
In Form View, you will use the Visible Property

See my posts above this also.

mx
0
Derek BrownMDAuthor Commented:
Good greif It apears that I cannot even manage to set the focus without an hour work. It is not even an option in the expression builder.
Project is main form details is sub.  I get command or action is not available now on run command???
Private Sub Toggle_Click()
    Forms![ProjectForm]![Details].SetFocus
    [Details].SetFocus
If Toggle = 2 Then
    DoCmd.RunCommand acCmdDatasheetView
Else
    DoCmd.RunCommand acCmdFormView
End If
End Sub
0
Derek BrownMDAuthor Commented:
Sorry had Details.set focus twice.
Good greif It apears that I cannot even manage to set the focus without an hours work. It is not even an option in the expression builder.
Project is main form details is sub.  I get command or action is not available now on run command???
Private Sub Toggle_Click()
    Forms![ProjectForm]![Details].SetFocus
If Toggle = 2 Then
    DoCmd.RunCommand acCmdDatasheetView
Else
    DoCmd.RunCommand acCmdFormView
End If
End Sub
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Not sure what's up.  What you are doing is a bit ... um, unusual.

Can you upload the db and I will try to look at it later ... give details as to where things are at.

mx
0
Derek BrownMDAuthor Commented:
Hi Got this from 'tinternett

If Toggle = 2 Then
    DoCmd.RunCommand acCmdSubformDatasheetView
Else
    DoCmd.RunCommand acCmdSubformFormView
End If
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
best to upload the db if you can ...
mx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Derek BrownMDAuthor Commented:
Hi

It's 3.19 am here. I will send it tomorrow.

That code works well and I havent managed to break it yet.

Thanks.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Wait ... I'm confused. Sooo, it's working ?

mx
0
Derek BrownMDAuthor Commented:
Problem solved. Thanks for putting me on the right track.

The docmd subform thing works perfect but I am not sure what you would do if there were two subforms on one main.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.