By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

How to automatically change a forms view.

P: 2
Hi,

I have a form which opens another form. when a record is changed on the first form information changes on the second form.

The first forms view is on 'single form' but i want the second forms view as Datasheet.

I've set the second forms 'Default view' to 'Datasheet' and disabled all other views. but it will only go to datasheet view if if click the 'Datasheet' option in the Menu Bar or like method.

So I created a button with the following code:

Option Compare Database

Private Sub Command38_Click()
On Error GoTo Err_Command38_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormDS, acDataForm, 2, , acMenuVer70

Exit_Command38_Click:
Exit Sub

Err_Command38_Click:
MsgBox Err.Description
Resume Exit_Command38_Click

End Sub

It works and changes the form to 'Datasheet view', but when i change a record on the first form it changes the second forms view back to 'single form' view. Like this i have to press the button every time i want it back in 'datasheet' view. Very inconvenient. I've tried writing a DoCmd and many other commands on the "on current" and on other "events" of the forms properties, but to no avail.

Can somebody help me? I'm probably missing some simple point. Or just using the wrong method to make the form change its view with a code.

Thanks.

Lupus Dark
Dec 20 '07 #1
Share this Question
Share on Google+
1 Reply


P: 2
Sorry forgot to mention: I'm using Access 2003; Windows XP SP2

Thanks for any help with this.
Dec 20 '07 #2

Post your reply

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