Marchese Il Chihuahua
Marchese Il Chihuahua

Reputation: 1139

Opening a zoom window in MS Access

I am having an issue with opening a zoom window in a sub form.

Basically, I have created a pop up window (form) which is suppose to appear upon double clicking in a memo field in a sub form to allow the user to be able to zoom in on the field and have additional ease upon entering long sentences.

I believe the problem is linked to the fact that the form which I am trying to create the zoom window is actually a sub form embedded in a form. My reasoning behind this is due to the fact that my code works perfectly well when i open the sub form alone and double click on the zoom in field..

Below is the code. The subform name is 'frmMasterListOfEventsDetails", the control / field to zoom in on in the sub form is called "notes2". The pop up window (subform) is named "frmZoom" and its control (text box) where the information is to be entered is called "txtZoom".

I would appreciate any help you may have. Thank you

Private Sub Notes2_DblClick(Cancel As Integer)
    If Me.AllowEdits = False Then
        Messaggi.MessaggioExclamation
    Else
        Me.Refresh
        DoCmd.OpenForm "frmzoom", acNormal, , , , acDialog
    End If

End Sub


Private Sub Form_Close()
    Forms("frmMasterListOfEventsDetails")!Notes2 = Me.txtZoom
    Forms("frmMasterListOfEventsDetails").Refresh

End Sub

Private Sub Form_Open(Cancel As Integer)
    Me.txtZoom = Forms("frmMasterListOfEventsDetails")!Notes2
End Sub

Upvotes: 0

Views: 3164

Answers (3)

Gonty
Gonty

Reputation: 21

I'm late but you can just use the SHIFT+F2 to get a zoom a any textbox in Microsoft Access

Upvotes: 1

David
David

Reputation: 59

Probably, a better aproach (since you can reuse it on other forms) is this:

Private Sub Notes2_DblClick(Cancel As Integer)
    If Me.AllowEdits = False Then
        Messaggi.MessaggioExclamation
    Else
        Me.Refresh
        DoCmd.OpenForm "frmzoom", acNormal, , , , acDialog, Me!Notes2
        if IsOpened("frmzoom") then
            Me!Notes2 = Forms!frmzoom!txtZoom
            DoCmd.Close acForm, "frmzoom"
        end if
    End If
End Sub

'Independent module
Public Function IsOpened (stNameOfForm as string) As Boolean
    Dim i As Integer
    For i = 0 To Forms.count - 1
        If Forms(i).Name = stNameOfForm Then
            IsOpened = True
            Exit Function
        End If
    Next
End Function

'frmzoom module
Private Sub Form_Open(Cancel As Integer)
    Me.txtZoom = Me.OpenArgs
End Sub
Private Sub Btn_OK_Click() 'frmzoom Button OK
    Me.Visible = False
End Sub
Private Sub Btn_Cancel_Click() 'frmzoom Button Cancel
    DoCmd.Close
End Sub

As you can see, the zoom dialog receives the data from the form that calls it and then collects the information directly depending on the status (open / closed); thus the Zoom dialog does not need to know the name of any control and can be used by any form.

Upvotes: 0

parakmiakos
parakmiakos

Reputation: 3020

I believe the problem is linked to the fact that the form which I am trying to create the zoom window is actually a sub form embedded in a form

I believe you are correct. Since frmMasterListOfEventsDetails is a subform,

Forms("frmMasterListOfEventsDetails") 

will not find it. You need to go through the main form:

Forms("parentFormName").Form.frmMasterListOfEventsDetails.Form.Notes2 = Me.txtZoom

Upvotes: 1

Related Questions