Programatically change forms default view?

bhamilton42

Registered User.
Local time
Today, 13:35
Joined
Jul 30, 2012
Messages
16
Hello

I have toiled with this for the better part of 2 hours now and I need some help!

I have a form that I'm making for a user. I want it to be a continous form. There are 8 records in particular that my user should see thus, a continous form as aposed to a single form. The form in question is a subform. It start inittially invisible with a blank "record source". when the user clicks a button the "Record Source" property is set appropriately and the form is made visible. I did set the default view property to "continous forms" in the properties menu in design view. However, when the form becomes visible it only displays 1 record.

The problem lies not with my SQL, I created a query and copied and pasted it EXACTLY and it returns me the coreect 8 records. What it seems is happening is despite my setting the default view to "continuous forms" it is opening in "single form" view which I do not want.

I want to set the "default view" property to "continous forms" in my VBA code, however wherever I've tried doing that I get the error "to set this property open the form or report in design view". So, can anyone help?
 
I want to set the "default view" property to "continous forms" in my VBA code, however wherever I've tried doing that I get the error "to set this property open the form or report in design view". So, can anyone help?
So, have you tried setting it in design view.
Can you show us the line of code that makes it visible.
 
Bob,

I did set the default view in properties to "continous form. If I open the main form in design view, then put focus into the detail area of the subform, then go to form view, then click the button to make the subform visible it displays properly. but obviously I can't have my users doing this.
(I have also tried many combinations of "set focus" thrown in there.

Here as requested are the 2 lines from my button click

Code:
"my_subform.Form.RecordSource = "SELECT table.field, Count(*) AS test FROM table WHERE (((table.[other_field])='D')) GROUP BY table.field; "

Code:
"my_subform.Visible = True"
and i've also tried refresh and requery and other things too.

Hope you can help
 
Are you meaning the main form needs to be in continuous view or the subform? If the subform, then open the subform itself in design view and set it's default view to Continuous. Is there another view you need it to be able to do or just continuous? If just continuous then set it like I said.

Now, if you created your form by the wizard and it automatically put the subform in there for you, it probably isn't really a subform (it automatically puts the TABLE in there). So, create an actual form for that table and then delete the current "subform" and drag and drop that form you created onto the main form. Then it should be able to show continuous.
 
Other bob,

I did create a seperate form and then dragged it over to be a subform on my main form. I also DID put the default view to continous on that SUBFORM. (the main form is in form view, the sub form is in continous form)

However, even with the subforms default view set in properties to continous, it still only shows 1 record at a time. unless as i said prior to opening, i go into design view, click into the detail area of the subform, then click form viewon the main form. then when i click the button the form shows all 8 records.

So again, can I use vba to set the forms default view? the help methods say I can but I can't find a place where it will let me.
 
Can you post a copy of the database with bogus data so we can see? I might be able to see what's happening. (if you do, make sure to run compact and repair first and then right-click the file and select SEND TO > COMPRESSED FOLDER to zip it)
 
I unfortunately wold not be able to do that. My employer would not aprove. I assume then that there is no simple command to just say my_subform.form.defaultView = 1? it seemed so simple, but then it kept on insisting I do it in design view. *sigh* what a fickle creature is access. I shall have to rework things a great deal to get around this.

Thanks guys for trying to help!
If I do manage to figure this out by sonme fluke I'll post the message for others.
 

Users who are viewing this thread

Back
Top Bottom