Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / November 2007

Tip: Looking for answers? Try searching our database.

Sub Pop-up Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sally - 15 Nov 2007 19:16 GMT
I would like to create a sub-form that is also a pop-up form so that the form
will float on top of the other screens.  The data on this form will be
various tools using a checkbox for each that users could select (multiple
selection is expected).  If I want to be able to run a query to see which
records used which tools do I need to add a new field for each tool?  Or, can
I create a table with all of the tools?

Thanks.
Steve McLeod - 15 Nov 2007 20:44 GMT
In the example below you can use frm_detail.SetFocus to put your "popup"
form on top.  Also, you can hide and display it with frm_detail.Visible =
True/False

Open a sub form from a parent form and set up two way calling.

' In a module
Public Function IsOpen(strForm As String) As Boolean
   IsOpen = (SysCmd(acSysCmdGetObjectState, acForm, strForm) > 0)
End Function

' In frm_Calling
Private frm_detail As Form_frm_detail

   If IsOpen("frm_detail") And Not frm_detail Is Nothing Then
       frm_detail.CallingName = strTargetKeyString
   Else
       DoCmd.OpenForm "frm_detail", _
           DataMode:=acFormEdit, _
           WindowMode:=acWindowNormal, _
           OpenArgs:=Trim(CStr(lngRecordID)) & "^" & strTargetKeyString &
"^" & Me.Name
       Set frm_detail = Application.Forms("frm_detail")        
   End If
   
' If the calling form is a subform then the above open must use the parent
form name
' Use Parent.Name rather than Me.Name

' ****In frm_detail*****

Private ParentForm As Form
Private ParentFormName As Variant
Private lngRecordID As Long

Property Set ParentObject(fValue As Form)
   Set ParentForm = fValue
   ParentFormName = ParentForm.Name
End Property

Property Let CallingName(vValue As Variant)
   ' put code in here to initialize your form
   ' run a parameterized query to retrieve the desired records
   ' set default values for controls
End Property

Private Sub Form_Load()
   Dim lngOne As Long
   Dim vTargetKey As Variant
   Dim vCallingForm As Variant
   Dim vInstanceID As Variant
   
   If Not IsNull(Me.OpenArgs) Then
       
       lngOne = 1
       vInstanceID = Trim(Nz(Left(Me.OpenArgs, InStr(lngOne, Me.OpenArgs,
"^") - 1), ""))
       lngOne = InStr(lngOne, Me.OpenArgs, "^") + 1
       vTargetKey = Trim(Nz(Mid(Me.OpenArgs, lngOne, InStr(lngOne,
Me.OpenArgs, "^") - lngOne), ""))
       lngOne = InStr(lngOne, Me.OpenArgs, "^")
       vCallingForm = Trim(Nz(Right(Me.OpenArgs, Len(Me.OpenArgs) -
lngOne), ""))
       Set ParentObject = Application.Forms(vCallingForm)
' If the calling form is a subform use the following
'        Set ParentObject =
Application.Forms(vCallingForm).subformcontrolname.Form
       lngRecordID = CLng(Nz(vInstanceID, "0"))
       CallingName = vTargetKey ' A method to initialize the form
       
   End If ' If Not IsNull(Me.OpenArgs) Then
End Sub

' Now each form can call methods in the other

Signature

Pictou

> I would like to create a sub-form that is also a pop-up form so that the form
> will float on top of the other screens.  The data on this form will be
[quoted text clipped - 4 lines]
>
> Thanks.
Sally - 15 Nov 2007 20:54 GMT
Thank you, Steve.

> In the example below you can use frm_detail.SetFocus to put your "popup"
> form on top.  Also, you can hide and display it with frm_detail.Visible =
[quoted text clipped - 79 lines]
> >
> > Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.