Jumat, 30 September 2011

RE: [MS_AccessPros] Open Multiple Instances of a Form, each to a specific record

 

Amy-

Revise the function to accept a filter string:

Function OpenAfrmFY12Targets1Edit(Optional strFilter As String = "")
'Purpose: Open an independent instance of form frmFY12Targets1Edit.

Dim frm As Form

'Open a new instance, show it, and set a caption.
Set frm = New Form_frmFY12Targets1Edit

' See if passed a filter
If Len(strFilter) > 0 Then
' Apply the filter before revealing the form
frm.Filter = strFilter
frm.FilterOn = True
End If

frm.Visible = True
frm.Caption = frm.Hwnd & ", opened " & Now()

'Append it to our collection.
clnfrmFY12Targets1Edit.Add Item:=frm, Key:=CStr(frm.Hwnd)

Set frm = Nothing
End Function

When you call the function, you can now pass it a parameter containing the
filter you want to apply.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of amy_hollows
Sent: Friday, September 30, 2011 9:13 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Open Multiple Instances of a Form, each to a
specific record

John,

Thanks so much for the quick reply. This is my first time joining a MS Access
group and so far so good! :) Here is the code I used to open independent
instances of my form:

Option Compare Database

Public clnfrmFY12Targets1Edit As New Collection
'Instances of frmFY12Targets1Edit.

Function OpenAfrmFY12Targets1Edit()
'Purpose: Open an independent instance of form frmFY12Targets1Edit.

Dim frm As Form

'Open a new instance, show it, and set a caption.
Set frm = New Form_frmFY12Targets1Edit
frm.Visible = True
frm.Caption = frm.Hwnd & ", opened " & Now()

'Append it to our collection.
clnfrmFY12Targets1Edit.Add Item:=frm, Key:=CStr(frm.Hwnd)

Set frm = Nothing
End Function

I would like to call this function on a double-click event of a record in a
"search form" that I have created and pass it an argument (i think this is the
correct terminology) to open to a specific record. The "search form" has an
AutoNumber field that uniquely identifies each record. The "search form" allows
users to search by up to 3 criteria and returns a list of records in a
continuous form. I want the user to be able to double-click on a record (or a
button or whatever...I can just decide later where to set the dbl click event)
to open a separate "edit form" to edit the record. The user will often need to
edit 2+ records at a time, thus the need for opening multiple instances of a
form (to a specified record).

Thanks in advance for your help. :)

amy

--- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@...> wrote:
>
> Amy-
>
> Because you open multiple copies be setting an object reference to the form's
> class module, you can use that object to manipulate the form, including
setting
> the Filter and FilterOn properties or doing a search on the Recordset to move
to
> a specific record. Post the code you're using now with a more detailed
> description of how you want to apply a search, and I can probably give you the
> modifications you need.
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of amy_hollows
> Sent: Thursday, September 29, 2011 4:50 PM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: [MS_AccessPros] Open Multiple Instances of a Form, each to a specific
> record
>
> I have used code from Allen Browne to successfully open multiple instances of
a
> form in my database (pretty sweet). Now, I would like to be able to open the
> instances of this form to a specific record, which is specified in the search
> results of another form that I created that searches a table based on 3
> criteria. I can do these two things separately (open multiple instances, and
> open a form to a specific record). Any ideas on how to combine these two
ideas
> into something work-able for me?
>
> (P.S. I am now at the "cut and paste and modify and debug" stage of VB
> programming so bear with me if my questions sound totally vague. I'm super
> excited about programming and making this db work though, so any help is much
> appreciated!)
>
> thanks!
>
> ~Amy
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>

------------------------------------

Yahoo! Groups Links

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar