parameters for new instance of a form

S

SandyR

I have a database with a switchboard, a complaint form, and a related
complaints form. I want to be able to open multiple instances of both the
complaint and related complaints form. Furthermore, I want the related
complaints form to select the related records based on the value of an option
group on the complaint form (i.e. related by street address or related by
complainant name). I would like to use the same related complaint form in
both cases. Also, when the user clicks a record in the related complaint
form, I want an additional instance of the complaint form to open with the
selected record.

I have read Allen Browne's article on managing multiple instances. I am
putting the collections and the code to manage them into the switchboard's
module. So when someone clicks to see related complaints, the public
function in the switchboard opens the instance of the related complaints
form. What has me stymied, is how to pass the field name (either street or
last name) and value to the form so that I can set the bookmark to the first
record with that value. Since I am not using DOCMD to open the form, I
don't see how to get this info across.

Here is my function (in the switchboard module) to open the related
complaints form, without setting up for the bookmark:

'---------------------------------------------------------------------------------------
' Procedure : OpenRelated
' DateTime : 1/5/2007 10:21
' Author : rosensan
' Purpose : create a new instance of the related records form,
' append it to the collection, and sort appropriately
' by setting its properties
'---------------------------------------------------------------------------------------
'
Public Function OpenRelated(sortkey As Control, KEYVALUE As String)
Dim frm As Form
On Error GoTo OpenRelated_Error
' Create a new instance of the form
Set frm = New Form_related_complaints
' use the parameter to set the sort order
frm.OrderBy = sortkey
frm.OrderByOn = True
frm.Visible = True
frm.Caption = frm.Hwnd & " related by " & sortkey
' append it to our collection
clnrelatedForm.Add Item:=frm, Key:=CStr(frm.Hwnd)
Set frm = Nothing


OpenRelated_exit:
On Error GoTo 0
Exit Function

OpenRelated_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure
OpenRelated of Module service records module 1"
Resume OpenRelated_exit
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top