473,657 Members | 2,993 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a record index to a function that opens a form for that index?

sueb
379 Contributor
I have a function that opens instances of a form when called from the switchboard. However, now I want to open a specific record, but I don't know how to pass/receive the record index.

The structure of my database is such that I have a master table (patients) and a child table (procedure requests), and the index I want is available from the master table's form, on which there is a button that can provide the desired index. (It actually currently does that, but without using the form collection object, which is new.)

Here's the form-opening function (there is an associated collection, and appropriate form-closing functions):

Expand|Select|Wrap|Line Numbers
  1. Function OpenAnIURClient()
  2.     'Purpose:   Open an independent instance of form frmClient.
  3.     Dim frm As Form
  4.  
  5.     'Open a new instance, show it, and set a caption.
  6.     Set frm = New Form_Sorted_by_IUR
  7.     frm.Visible = True
  8.     frm.Caption = frm.Hwnd & ", opened " & Now()
  9.  
  10.     'Append it to our collection.
  11.     clnIURClient.Add Item:=frm, Key:=CStr(frm.Hwnd)
  12.  
  13.     Set frm = Nothing
  14. End Function
  15.  
and here is the button's code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Open_IUR_Subform_Click()
  2. On Error GoTo Err_Open_IUR_Subform_Click
  3.  
  4.     Dim stDocName As String
  5.     Dim stMainForm As String
  6.     Dim stLinkCriteria As String
  7.  
  8.     stMainForm = "Patient_IUR_Overview"
  9.     stSubForm = "IURs Abbreviated: subform"
  10.     stDocName = "IURs: subform"
  11.     'stDocName = "Sorted_by_IUR"
  12.  
  13.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
  14.  
  15.     stLinkCriteria = "[IURs.IUR Index]=" & Me![IUR Index]
  16.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  17.     'OpenAnIURClient ' Need to be able to pass the link criteria to this
  18.  
  19. Exit_Open_IUR_Subform_Click:
  20.     Exit Sub
  21.  
  22. Err_Open_IUR_Subform_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Open_IUR_Subform_Click
  25.  
  26. End Sub
  27.  
I think this should be fairly straightforward , but I just don't know the syntax.
Jan 19 '11 #1
9 1769
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Hi there
Im not really familier with your way of using instanced forms, so this is a guess at a method to use. Modify the first function:
Expand|Select|Wrap|Line Numbers
  1. Function OpenAnIURClient(Optional strFilter as string="")
  2.     'Purpose:   Open an independent instance of form frmClient. 
  3.     Dim frm As Form 
  4.  
  5.     'Open a new instance, show it, and set a caption. 
  6.     Set frm = New Form_Sorted_by_IUR 
  7.     frm.Visible = True 
  8.     frm.Caption = frm.Hwnd & ", opened " & Now() 
  9.  
  10.     if strFilter & ""<>"" then
  11.       frm.Filter=strFilter
  12.       frm.FilterOn=True
  13.     end if
  14.     'Append it to our collection. 
  15.     clnIURClient.Add Item:=frm, Key:=CStr(frm.Hwnd) 
  16.  
  17.     Set frm = Nothing 
  18. end Function
And then call the function like:
Expand|Select|Wrap|Line Numbers
  1.  stLinkCriteria = "[IURs.IUR Index]=" & Me![IUR Index] 
  2.  OpenAnIURClient stLinkCriteria
Jan 21 '11 #2
NeoPa
32,568 Recognized Expert Moderator MVP
When using the syntax that opens multiple instances of a designed form in your database (Set frm = New Form_blahblah), you are specifically not using the normal syntax which would allow you specify stLinkCriteria (WhereCondition) or OpenArgs parameters. The former allows you to specify a filter condition to the instance of the form, and the latter allows you to pass across information that the code in your form can use for whatever it likes (in this case it might want to navigate to the specified record).

The options I can see are to :
  1. Apply a filter to the form externally -
    Expand|Select|Wrap|Line Numbers
    1. frm.Filter = "Blah blah"
    2. frm.FilterOn = True
  2. Design a public procedure in the form that you could call externally, passing the value of the required record -
    Expand|Select|Wrap|Line Numbers
    1. Call frm.YourPubProc("Blah blah")
    The procedure would take the necessary steps either to filter the data, or to navigate to the specified record. Your choice.

PS. This use of forms (multiple instances etc) is generally considered quite advanced stuff. I would guess very few Access programmers have ever used it. Just so you understand where you're at with this Sue. It's not super difficult once you get your head around it, but very few will have experience to share I expect.
Jan 21 '11 #3
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Im guessing the need to have multiple instances of the same form is that you want to have several windows(form) open at the same time? Is that the case?

Otherwise please do me a favour and explain why you use instanced forms.

TheSmileyCoder
Jan 21 '11 #4
NeoPa
32,568 Recognized Expert Moderator MVP
I can't answer for Sue, but the typical reason is the potential for multiple instances open together. This could include the requirement to have multiple windows doing an ostensibly similar job, but could also include a form of more generic use that would generally be used where necessary, with the possibility, in certain circumstances only, that more than one instance could be active concurrently. An example that comes to mind is an info form that indicates a certain state relative to another form. EG. that an activity is in process.
Jan 21 '11 #5
sueb
379 Contributor
Thanks to both of you for these ideas--I haven't had a chance to try them yet, but I thought I could at least clear up why I'm doing this. My users need to be able to review the records of multiple patients at one time, not for the purposes of comparing any of the data, but because their work flow is very interruptible: among other things, they both work on a single patient's record for a long period, and intermittently have to respond to phone interruptions about other patients' information.

If they can simply minimize one patient's window and then open a separate window, it really makes their lives easier.

Currently I have two different forms that are copies of each other: the "sub"-window is being called from the master record (that's the "Open_IUR_Subfo rm_Click" module) and opens a specific window, and the "independen t" window (that's "OpenAnIURClien t") opens from the switchboard and just opens on the first record.

I really need to get rid of one of these windows and make it able to be opened either with or without a record pointer (keeping them in synch is driving me crazy!), so that's the point of this question.
Jan 21 '11 #6
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Thank you for taking the time to explain this. It makes good sense to attack the problem like you have.

Part of the reason (Besides the best access experts on the net) I browse through this forum is because I often see people attacking a problem in ways I didn't even think off. While I don't have an immediate need to use something like this I can imagine some areas of my applications where it would be Nice to Have, and certainly add value.

Thank you, I hope you get something working and report back here. If you run into more trouble, please come back :)
Jan 21 '11 #7
sueb
379 Contributor
TheSmileyOne, this fix was so fast and slick it almost knocked me off my chair as it went in! It works perfectly, and (always a plus) really neatened up the code.
Jan 21 '11 #8
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Im smiling to hear that :)
Jan 23 '11 #9
NeoPa
32,568 Recognized Expert Moderator MVP
But ... but ... You're always smiling!
Jan 23 '11 #10

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

Similar topics

1
3192
by: Richard Coutts | last post by:
I have a Continuous Form where each record has a button that activates another form that simplifies entering values into the record. The activated form has the equivalent of a "Done" button. I'd like to write an OnClick event that populates the contents of the current record of the parent form with the values entered in the popup form. So, the activated form needs to set the values of the current record of the parent form. How do you...
0
1101
by: Lisa Jones | last post by:
Hi Has anyone see this problem in ADO.Net when deleting a record (assuming that the table has identity increment Index) result in getting wrong index key if right after adding the record the table query for the added recorded Index key. Anyone knows what would be the best way to solve this problem Clearing dataset and refilling it won’t work if you are using web services. Any suggestion or help will be highly appreciated Thank Lisa...
6
3794
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after you enter data to the first field on the main form (a VIN#), that is not the case. The SubForm control becomes disabled and will not accept the focus. Dunno why. There's no child/master link fields. They have no settings - at least not in design...
3
2411
by: Cylix | last post by:
I have a form that contains around 20 input elements, they have some onclick event on it. I would like to know how can I get the form element index when the onclick event fire. I found no property or method to do so. Thank you.
2
2554
by: whitc26 | last post by:
Let me preface: I'm a novice, and have no programming experience. I have created an access database and have a few tables in it. I have created a form called "clients" This form opens up and has alot of basic client information in it, nothing fancy, no code (other than what access has put in). I have created a second form "newVisit" This form has a subform on it called "client visit subform". The form is just to be used to record...
5
3481
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record the cursor was on in the datasheet at the time I executed the macro. So, the questions are: 1) In the macro, how to I get my hands on the record key or record data of the record the cursor was on in the datasheet at the time I executed the...
2
1789
by: BerkshireGuy | last post by:
I have a form that acts like a dashboard to show summarized data. Currently, this form gets its summarized values from a total's query. When the user selects to run the dashboard, they should be able to run company wide (all agencies) or specific agencies. So I figured I evaulate in code what they want and pass an where clause based on their selection using Do I am having trouble passing the where clause. It keeps prompting me
9
1836
momotaro
by: momotaro | last post by:
hi every one im trying to pass to a function an array with its index: //this is my struct typedef struct{ char word; int anagrams; }Word; //this is the prototype of the function: int find_anagrams(char **, char **);
1
3241
by: Martin Bentler | last post by:
Right now, I have a form, locked records, on which I have a CommandButton that opens a second form (much like the first) but open for editing, plus allowing the user to manipulate other areas of the data base. I want to have the second form open at the specific record I was working with on the first form. Basically what I am doing is running a find to locate the record after the second form opens, as all I have is DoCmd code to open and close...
3
8902
by: extrym | last post by:
I have 2 forms, "Staff" and "Security" (without the ""'s). The Staff form has the following fields: staff_ID staff_name staff_number staff_DOB priority The Security form contains the following fields: staff_ID staff_pass
0
8384
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
8718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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,...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
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
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
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.