Forms: Popup for a memo field using the toggle button

V

Veli Izzet

Hi All,

I want to view/hide the Notes (Memo field) of a record in a pop-up
window using a toggle button, when I am in a form.

How do I write the code?

Thanks for answers,
 
V

Van T. Dinh

You can simply use the inbuilt ZoomBox with code for the CommandButton as
follws:

Private cmd_Click()
Me.MemoTextBox.SetFocus
DoCmd.RunCommand acCmdZoomBox
End Sub
 
G

Gary Walter

Veli Izzet said:
I want to view/hide the Notes (Memo field) of a record in a pop-up window
using a toggle button, when I am in a form.

How do I write the code?
Hi Veli,

PMFBIA


Here are 2 examples from some of
my databases that use a different method:

1) textbox control "txtMsgBody" (and its label "lblMsg")
(bound to memo field)

Private Sub cmdToggleMsg_Click()
txtMsgBody.Visible = Not txtMsgBody.Visible
lblMsg.Visible = Not lblMsg.Visible
End Sub


2) subform container "contSubActualEnr"

Private Sub cmdToggleSubForm_Click()
Me!contSubActualEnr.Visible = Not Me!contSubActualEnr.Visible
Me!contSubActualEnr.Enabled = Not Me!contSubActualEnr.Enabled
If Me!contSubActualEnr.Visible = True Then
Me!contSubActualEnr.SourceObject = "frmSubActualEnr"
Else
Me!contSubActualEnr.SourceObject = ""
End If
End Sub

In the case of the container for the subform,
the data it displayed was only needed at certain
times in the business cycle, and the subform used
so much conditional formatting, that it sped up
the main form by hiding AND unbinding the container
when not needed (but VERY helpful that one time
in the process when they needed to see it).

Apologies again,

gary
 
G

Gary Walter

Wow...there's another case of missing "Me!"

Private Sub cmdToggleMsg_Click()
Me!txtMsgBody.Visible = Not Me!txtMsgBody.Visible
Me!lblMsg.Visible = Not Me!lblMsg.Visible
End Sub
 
V

Veli Izzet

Gary,

In your first option, and V. Dinh's option there need to be a text
control and label on the form.

Your first option is not a pop-up, can you explain some more the
container option? I did not quite understand it..

How do I define the container, so that it will be called?

Sorry if that is very trivial..
 
G

Gary Walter

HI Veli,

I'm sorry...I must have misunderstood.

I thought you had a form that showed
the field "Notes" of a record in a text box.
By clicking on the command button,
this textbox would be shown or not shown.

I guess I don't understand what you
mean by pop-up window.

To me that would mean another form
that your command button would open
or close, which had a textbox in it showing
the memo field "Notes" for the current record?

If so, you create a small form (say "frmPopUp")
with an unbound textbox (say "txtPopUpNotes").
make it a modal, popup form.

On your original form create a hidden
textbox bound to "Notes" (say "txtNotes").

The code for your toggle command button
would check if "frmPopUp" is open...

If not open,

open frmPopUp passing contents of txtNotes
in OpenArgs....then in Form_Open event of frmPopUp
assign OpenArgs to txtPopUpNotes.

If open,

close frmPopUp

------------------
So code for your main form might look like:

Public Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet
view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Private Sub cmdToggleMsg_Click()
If Not IsLoaded("frmPopUp") Then
DoCmd.OpenForm "frmPopUp", , , , acDialog, Me!txtNotes
Else
DoCmd.CloseForm "frmPopUp"
End If
End Sub

-----------------
and code for your popup form might be:

Private Sub Form_Load()

If Len(Me.OpenArgs & "") > 0 Then

Me!txtPopUpNotes = Me.OpenArgs

Else

Me!txtPopUpNotes = "No Notes."

End If

End Sub
 
V

Veli Izzet

Thanks for all the help, it is done..



Gary said:
HI Veli,

I'm sorry...I must have misunderstood.

I thought you had a form that showed
the field "Notes" of a record in a text box.
By clicking on the command button,
this textbox would be shown or not shown.

I guess I don't understand what you
mean by pop-up window.

To me that would mean another form
that your command button would open
or close, which had a textbox in it showing
the memo field "Notes" for the current record?

If so, you create a small form (say "frmPopUp")
with an unbound textbox (say "txtPopUpNotes").
make it a modal, popup form.

On your original form create a hidden
textbox bound to "Notes" (say "txtNotes").

The code for your toggle command button
would check if "frmPopUp" is open...

If not open,

open frmPopUp passing contents of txtNotes
in OpenArgs....then in Form_Open event of frmPopUp
assign OpenArgs to txtPopUpNotes.

If open,

close frmPopUp

------------------
So code for your main form might look like:

Public Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet
view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Private Sub cmdToggleMsg_Click()
If Not IsLoaded("frmPopUp") Then
DoCmd.OpenForm "frmPopUp", , , , acDialog, Me!txtNotes
Else
DoCmd.CloseForm "frmPopUp"
End If
End Sub

-----------------
and code for your popup form might be:

Private Sub Form_Load()

If Len(Me.OpenArgs & "") > 0 Then

Me!txtPopUpNotes = Me.OpenArgs

Else

Me!txtPopUpNotes = "No Notes."

End If

End Sub
 
G

Guest

Van T. Dinh said:
You can simply use the inbuilt ZoomBox with code for the CommandButton as
follws:

Private cmd_Click()
Me.MemoTextBox.SetFocus
DoCmd.RunCommand acCmdZoomBox
End Sub
 
Top