473,661 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set the RecordsetType for a subform OnOpen of the main form?

sueb
379 Contributor
ADezii helped me with this once, but I must have messed it up somehow and can't figure it out again!

All my forms are opened either in Dynaset or Snapshot mode, depending on whether the user has put in the correct password. One of my forms (Patient_IUR_Ov erview) has a subform (IURs_Abbreviat ed_subform), and I had the following code in the main form's OnOpen event, which was working great:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     If ReadOnly Then
  3.         Me![IURs_Abbreviated_subform].Form.RecordsetType = conSnapshot
  4.         Me![Add_New_Chart].Visible = no
  5.     Else
  6.         Me![IURs_Abbreviated_subform].Form.RecordsetType = conDynaset
  7.     End If
  8. End Sub
  9.  
Now, however, I'm getting an error that says it can't find "the field" IURs_Abbreviate d_subform. It didn't used to think this name was a field, but correctly recognized it as the name of the subform (the control and the subform itself have the same name).

I'd made some changes before I began to see this error, but couldn't identify what caused this. I'm uploading my front end and some dummy data. The password can be found in the Passwords module; the trouble comes when selecting "Pre-Admitting" (from the main menu), and then "Patient / IUR Overview" from the next menu.

Thanks to anyone who can help me with this!
Attached Files
File Type: zip IURs.zip (643.0 KB, 107 views)
Feb 11 '11 #1
4 3515
ADezii
8,834 Recognized Expert Expert
Try:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.   If ReadOnly Then
  3.     Me![IURs_Overview].Form.RecordsetType = conSnapshot
  4.       Me![Add_New_Chart].Visible = False
  5.   Else
  6.       Me![IURs_Overview].Form.RecordsetType = conDynaset
  7.   End If
  8. End Sub
Feb 11 '11 #2
sueb
379 Contributor
That did it, ADezii!

What do you think it is in my mental model that is keeping me from being good with this? I have a pretty good understanding of points and attributes and all that kind of stuff, but in other languages. I just can't seem to get a firm grip on Access/VBA's underlying structure. I don't suppose you could recommend a decent language manual, could you? You know, one that assumes you already know how to design stuff, but just need the vocabulary, etc. for Access/VBA...

Anyway, thanks again for coming to my rescue!
Feb 11 '11 #3
ADezii
8,834 Recognized Expert Expert
There are many good references out there, sueb, and I really don't know if any one is better than the other. One thing that I can tell you is that your recent problems revolve around differentiating between an actual Sub-Form, and the Sub-Form Control that actually contains the Sub-Form. These are not one and the same thing. There are actually few instances where you would be addressing the Sub-Form itself by name, usually it will be the Control containing it. Learning the difference between the two would be a good starting point. Good Luck.

P.S. - As far as VBA goes, you cannot conceivably know details on every Property, Method, Event, Syntax, etc. on Components. The key, at least for me, if to know which Property, Method, Event, etc. is applicable in any given situation. Looking up the correct Syntax, then, is a simple matter since the Help Files are pretty much comprehensive in most cases.
Feb 12 '11 #4
sueb
379 Contributor
That's very helpful, ADezii, and is just the sort of thing I need. I don't expect to know details for everything; I'd just like to be able to know what "element" I need to be researching. That's what I meant by understanding the underlying structure. Thanks again!
Feb 15 '11 #5

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

Similar topics

0
1950
by: Ellen Manning | last post by:
I've got an A2K form with a subform based on a query. This query has a checkbox and an amount field and returns records if checkbox is checked. I Dsum the amount field and display on the main form. If the user unchecks the box, I want the corresponding amount subtracted from the total. If they recheck the box, the amount is to be added. I want all records to appear on the subform even after unchecking them. This works fine...except......
0
2747
by: Colin | last post by:
In access 2000 I need to filter records in a Subform by pushing a button on a command button located on the Main form. The Main form is blank. Its only purpose is to contain the subform which is in a datasheet format. So far… 1)I have created a query called "CatFilterQuery" which results in a prompt to enter the "category field" to filter on. 2)Created a macro called "FilterCategory" which is based on the query mentioned above and uses...
1
3359
by: New2Access | last post by:
Hi, I have a form thats used to enter records into a table. The table and form have fields for Name, week, project, and hours. To assist users, I wish to add a subform that will show them how many hours and for which projects they've already made entries. To do this, I created a query based on the same table with criteria pointing to the current user, and the week selected in the main form. This seems to work fine except the...
18
13592
by: Darryl Kerkeslager | last post by:
I don't do much with subforms - in fact I've deliberately avoided them - but .... I have a tab control that will contain several subforms, each bound to a separate table, and each table/subform will relate to the same person - but the subform data will not be 'linked' to the main form. I want to have one Cancel button for all the undo operations on all the subforms, so the individul subform's Public Sub, Form_Cancel will be called...
1
2150
by: NBruch | last post by:
Ok let me explain what im trying to do: i need a combo box which needs to be linked to a listbox (or combo box doesnt matter which really) then the listbox should bring up the record in a subform. so you pick a name (in the combo box in the main form) then it should bring up all the dates for which the person has a record for (in the list box or combo box) and then once you pick a date it should bring up the specific record you want...
1
4705
by: luv4nrt | last post by:
Hello all, I have a membership dB in which I have a form that updates data in 4 tables. One of the tables is bounded to a subform within the Main membership form. I am trying to link all four tables, such that when I input data on the Main form it automatically populates data on all 4 tables. I was able to update 3 of the four forms using the SetValue (=) statement in the VB editor; however, I am not able to update the data on the...
3
2406
by: virtualgreek | last post by:
Dear all, I have a scenario that is driving me nuts. (MS Access 2003) I have a form/subform (Continuous form) where it gets its data from tables Order and Order_Details. In the footer section of the subform I have a hidden textbox named txtOrder_Total_Amount which displays the total of the whole order. On the main form I have a bound contol from the Order table, namely Order.Order_Total_Amount_Euro On the subform I have fields such...
1
2410
by: Elainie | last post by:
I have a main form and in it I have a datasheet subform filtered on surname, I would like the users to select a name in their list on the subform then the data moves up into the main form... Is there a way of doing this? Tried a lot of different things but it doesnt want to play... HELP!
2
6491
by: post | last post by:
Sorry that this is rather basic. But I have tried the various suggestions given in this group and cannot get them to work. I have a main form, for simplicity called "Main". On it are two subforms. For simplicity subform1 and subform2. subform1 lists fees for items. The sum of all fees for all items is in a text box on the footer of subform1. PurSum =Sum(). subform2 contains exactly the same field, fees for items of a different...
4
6193
by: Savita23 | last post by:
Hi, I have a subform in datasheet layout embedded in the main form.I want to invoke a procedure on the double click of each record in the subform.Is there a away by which I can fire the double click event of Detail section of the subform from the main form?I can't find this event. As of now,I am invoking the procedure in the Form_DblClick event of the subform.But this invokes the procedure when I double click on any part of the subform.I...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.