Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    California, USA
    Posts
    25

    Question Unanswered: Listbox Popup Menu

    I'm creating a shortcut menu to popup over my richtext box. Its a form with a listbox of menu items with associated richtext activex (rtf) editing commands. My problem is transferring the rtf editing commands as strings from the listbox popup menu over to the main form that has the richtext box that I am editing. I made a Public Function in a module that should captures the string from the menu and an event subroutine in the main form that is suppose to call the string from the Public Function. The codes are as follows:

    The Public Function in a module
    Code:
    ======================================

    Public pvarRftMenuString As String

    Public Function GetRftMenuString()

    Dim ctlCurrentControl As Control
    Dim frmCurrentForm As Form
    Dim strControlName As String
    Dim frm As Access.Form

    Debug.Print Application.Screen.ActiveForm.Name

    Set frmCurrentForm = Screen.ActiveForm 'Return form object pointing to active form.
    Set ctlCurrentControl = Screen.ActiveControl 'Return control object pointing to active control.
    Set frm = frmCurrentForm

    strControlName = ctlCurrentControl.Name
    Debug.Print strControlName
    pvarRftMenuString = frm.Controls(strControlName).String

    End Function
    ======================================

    The event subroutine in the main form.
    Code:
    ======================================

    Private Sub RichText1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Long, ByVal Y As Long)
    If Button = acRightButton Then
    Call rftMenu
    End If
    Call GetRftMenuString
    End Sub
    ======================================

    I can't get this to work. Can someone help me in transferring a string value between forms?

    Thanks,
    PC

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    pvarRftMenuString = frm.Controls(strControlName).String
    looks like the culprit!

    does
    pvarRftMenuString = strControlName
    do it for you?

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Jan 2004
    Location
    California, USA
    Posts
    25

    Listbox Popup Menu

    Thank you for your response. Your suggestion eliminated an error that I kept getting; but I have another question.

    In the main form I need to use a string variable to capture the value being transfered from the popup menu through the Public Function GetRftMenuString(). On the main form I need to Call GetRftMenuString() and capture the string in a string variable like strSelectedItem. Then call the function contained in strSelectItem.

    For example, to execute the command to make the selected richtext into bold format I have another Public Function that needs to be called after the value of the selected item is returned to the main form. In the case of the bold command the value returned from the popup menu and stored in strSelectedItem will be: rftBold() How can I call this function while in the main form from the value in strSelectedItem?

    Code:
    ======================================
    Public Function rtfBold()
    Dim frmCurrentForm As Form
    Dim ctlCurrentControl As Control
    ' Return Form object pointing to active form.
    Set frmCurrentForm = Screen.ActiveForm
    'Return control object pointing to active control.
    Set ctlCurrentControl = Screen.ActiveControl
    ctlCurrentControl.SelBold = (Not ctlCurrentControl.SelBold)
    End Function
    ======================================

    This function works, I just need to find a way to get the text out of GetRftMenuString() and then call the command contained in strSelectedItem while in the main form. Can you help me with this?

    Thanks

  4. #4
    Join Date
    Jan 2004
    Location
    California, USA
    Posts
    25

    Listbox Popup Menu

    I found a way to transfer a value from the popup menu to the form, but now I have one more step to take. The value being transferred is a public function from a module. I need to find a way to execute the function to edit the text in the richtext. See attached file and let me know if this is possible.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •