Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 36 of 36

Thread: Load Form in Personal Forms Library With VBA

  1. #21
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Again, I am not the expert re codes....I can just explain that in the form of the contact that each contact is created from, there are many additional fields that have words/dates that can be put in each field. And the other code in the script as commandbutton4, creates a task to the contact and in the form of the Task in the P2 area, there are fields that get the same words/dates from the contact fields. So the code I posted, simply updates the Task regarding that contact based on any changes to the fields in the Contact, and that upgrades the fields in the Task fields.....

  2. #22
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Post the RemoteCommandButtonClick code you tried. Before Paste it in, click the # button at the top of the Post editor and paste the code in between the two (Bracketed) Code Tags.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #23
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Sub ClickRemoteCommandButton() 
         
        Load Contact_Form_1 
        Contact_Form_1.btnUpdateTasks_Click 
        Unload Contact_Form_1 
         
    End Sub

  4. #24
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Are you sure that there are spaces in the name "Contact Form 1"?

    Try this

    Sub ClickRemoteCommandButton() 
         
        Load IPM.Contact.Contact Form 1
        IPM.Contact.Contact Form 1.btnUpdateTasks_Click 
        Unload IPM.Contact.Contact Form 1 
         
    End Sub
    If that doesn't do something, then I am truly stuck.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #25
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    I put it in a module....highlighted a contact, ran the macro and the error is:

    Compile error
    Syntax error

    And it colors the the load line

  6. #26
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Sorry, my friend, I'm stuck I have asked mrojas to take a look at this thread for you.

    I hope you get your answer.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  7. #27
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Any answer from someone else please?

  8. #28
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    How do you open the form manually? Record a Macro and manually open the form. Copy the Macro code and post it. Maybe that can help us understand the what to do.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  9. #29
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Thanks...here is the macro that opens up a new contact based on my the form I use.....

    Sub OpenMyContact()
    Dim oContact As outlook.ContactItem
    Dim oFolder As outlook.MAPIFolder
    Set oFolder = Application.Session.GetDefaultFolder(olFolderContacts)
    Set oContact = oFolder.items.Add("IPM.Contact.Contact Form 1.")
    oContact.Display
    End Sub

  10. #30
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Right.

    The next step must be done before we can go any further. And only you can do it.

    All the controls on your form must be properly named. There are certain standards for naming Form Controls:
    1. Labels do not need a custom name because they are not referenced in code.
    2. All controls referenced in the code must have a custom name.
    3. No spaces are allowed in Names
    4. The Names must indicate the name of the values of the Controls
    5. All custom names must start with a lower case prefix that indicates the control Type:
      • cbo = ComboBoxes (cboContacts)
      • txt = TextBoxes (txtIntroDate)
      • lbx = ListBoxes (lbxMyFriends)



    Open your Form in the VB Editor (VBE) and insure that the Properties window is View-able.

    You will see that every TextBox and ComboBox has a Label next to it. These Labels Name the Values of the Input controls. See #4 above.

    Following Rules 3, 4, & 5 above, one control at a time, first note the existing name of the Input Control and rename it in the Properties Window. Then View the code of the Form, press Ctrl+H to show the Replace Dialog. Check the boxes "Current Project," "Find Whole Word Only," and "Match Case." Put the old name in the Find What box and the new name in the Replace With box.

    Make sure you have the correct spelling of the old and new names. (you can use Ctrl+H to correct mistakes, but....)

    Press "Replace All."

    Repeat with the next Ctrl that needs a new name.

    When you have completed renaming all controls, post the new names code from
    Sub btnUpdateTasks_Click so we can doublecheck the Renaming for you.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  11. #31
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    I have a Userform and a Module related to it, and when I highlight a list of contacts in a folder, I run the Userform, it shows in the top Combobox the list of the fields that I have identified as part of a Contact form related to the Contacts I use, and and in Combobox re Value, it shows the drop list of words or dates that I can use to the specific field, and then when I click on the commandbutton in the Userform, it upgrades the field in all contacts I have highlighted putting in the words or dates that I have decided from the drop list.....
    And in the Module which makes this happen as to the User from, there is the separtate words If myValue = "Update Task Fields" Then and below that is the Script code from the Contact that upgrades the Task of the Contact...and in the Userform, where the Case is Case "btnUpdateTasks", and the value below it is Me.ddlValues.addItem "Update Task Fields"
    So when I upgrade the field of the Task date, and then run the Value "Update Task Fields", it runs the script and upgrades the Task of the contact I highlighted.....
    But what it does not do, is upgrade all contacts that I hightlighed re changing the Task field date.
    So is there something to change in the Userform or Module that will updgrade the Tasks of all Contacts I highlight, just how all Contacts are updgraded re the fields of words and dates?
    So first below is the Userform code and next is the Module code.
    So please let me known what to upgrade re the code or both codes so that it will upgarde the Tasks of all Contacts I highlight, just how all Contacts are updgrade re the fields of words and dates.

  12. #32
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Private Sub btnRun_Click()
    Dim Field As String
    Dim value As String
    Field = Me.ddlFields.Text
    value = Me.ddlValues.Text


    UpdateContactField Field, value

    Me.Hide

    End Sub
    Private Sub ddlFields_Change()
    Dim fld As String
    fld = Me.ddlFields.Text
    'Add your field related values here.

    Select Case fld


    Case "Initial Intro"
    Me.ddlValues.addItem ""
    Me.ddlValues.addItem "Words to Add"
    Me.ddlValues.addItem "Words to Add"


    Case "Intro Date"

    Me.ddlValues.addItem "None"
    Me.ddlValues.addItem " 9/21/2013 "
    Me.ddlValues.addItem " 9/20/2013 "
    Me.ddlValues.addItem " 9/21/2013 "
    Me.ddlValues.addItem " 9/22/2013 "
    Me.ddlValues.addItem " 9/23/2013 "
    Me.ddlValues.addItem " 9/24/2013 "
    Me.ddlValues.addItem " 9/25/2013 "
    Me.ddlValues.addItem " 9/26/2013 "
    Me.ddlValues.addItem " 9/27/2013 "
    Me.ddlValues.addItem " 9/28/2013 "
    Me.ddlValues.addItem " 9/29/2013 "
    Me.ddlValues.addItem " 9/30/2013 "
    Me.ddlValues.addItem " 10/1/2013 "
    Me.ddlValues.addItem " 10/2/2013 "
    Me.ddlValues.addItem " 10/3/2013 "
    Me.ddlValues.addItem " 10/4/2013 "
    Me.ddlValues.addItem " 10/5/2013 "
    Me.ddlValues.addItem " 10/6/2013 "
    Me.ddlValues.addItem " 10/7/2013 "
    Me.ddlValues.addItem " 10/8/2013 "
    Me.ddlValues.addItem " 10/9/2013 "
    Me.ddlValues.addItem " 10/10/2013 "
    Me.ddlValues.addItem " 10/11/2013 "
    Me.ddlValues.addItem " 10/12/2013 "
    Me.ddlValues.addItem " 10/13/2013 "
    Me.ddlValues.addItem " 10/14/2013 "



    Case "btnUpdateTasks"

    Me.ddlValues.addItem "Update Task Fields"

    End Select

    End Sub
    Private Sub UserForm_Initialize()
    'Add your field names here.

    Me.ddlFields.addItem "Initial Intro"
    Me.ddlFields.addItem "Intro Date"
    Me.ddlFields.addItem "btnUpdateTasks"


    End Sub

  13. #33
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Dim Selected As Integer
    X = 1
    Set objApp = Application

    On Error Resume Next


    Select Case TypeName(objApp.ActiveWindow)
    Case "Explorer"
    For Each item In objApp.ActiveExplorer.Selection
    Selected = objApp.ActiveExplorer.Selection.Count
    Do While X <= Selected
    Set myItem = objApp.ActiveExplorer.Selection.item(X)

    myItem.Visible = False
    myItem.UserProperties.item(FieldName).value = myValue


    If myValue = "Update Task Fields" Then



    Dim ContactName
    Dim olns
    Dim MyFolder
    Dim NumItems
    Dim myItems
    Dim TaskCount
    Dim Str, Str1, Str2, Str3, Str4, Str5, Str6, Str7, Str8, Str9, Str10, Str11, Str12, Str13, Str14, Str15, Str16, Str17, Str18, Str19
    Dim StartDate
    Dim DueDate
    Dim Recipients

    TaskCount = 0
    Str = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox7").value
    Str1 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox8").value
    Str2 = item.GetInspector.ModifiedFormPages("General").Controls("TextBox5").value
    Str3 = item.GetInspector.ModifiedFormPages("General").Controls("Initial Intro").value
    Str4 = item.GetInspector.ModifiedFormPages("General").Controls("Intro Date").value
    Str5 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox10").value
    Str6 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox3").value
    Str7 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox2").value
    Str8 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox4").value
    Str9 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox5").value
    Str10 = item.GetInspector.ModifiedFormPages("General").Controls("ContactTypeComboBo x1").value
    Str11 = item.GetInspector.ModifiedFormPages("General").Controls("TextBox4").value
    Str12 = item.GetInspector.ModifiedFormPages("General").Controls("StatusComboBox1"). value
    Str13 = item.GetInspector.ModifiedFormPages("General").Controls("TextBox20").value
    Str14 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox6").value
    Str15 = item.GetInspector.ModifiedFormPages("General").Controls("TextBox22").value
    Str16 = item.GetInspector.ModifiedFormPages("General").Controls("ComboBox9").value
    Str17 = item.GetInspector.ModifiedFormPages("General").Controls("Follow-Up ComboBox1").value
    Str18 = item.GetInspector.ModifiedFormPages("General").Controls("TextBox3").value
    Str19 = item.GetInspector.ModifiedFormPages("General").Controls("NextStepComboBox1" ).value
    StartDate = item.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl4"). value
    DueDate = item.GetInspector.ModifiedFormPages("General").Controls("OlkDateControl3"). value

    ContactName = item.GetInspector.ModifiedFormPages("General").Controls("Fullname").value
    Set olns = item.Application.GetNamespace("MAPI")
    Set MyFolder = olns.GetDefaultFolder(13)
    NumItems = MyFolder.items.Count
    Set myItems = MyFolder.items
    If NumItems > 0 Then
    For i = 1 To NumItems
    Set Recipients = myItems(i).Recipients
    If Recipients.Count > 0 Then

    If myItems(i).Links.item(1).Name = ContactName Then
    myItems(i).Display
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox20").valu e = Str
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox7").value = Str1
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox24").valu e = Str2
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox25").valu e = Str3
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox26").valu e = Str4
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox23").valu e = Str5
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox8").value = Str6
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox9").value = Str7
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox10").valu e = Str8
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox11").valu e = Str9
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox12").valu e = Str10
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox13").valu e = Str11
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox14").valu e = Str12
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox15").valu e = Str13
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox16").valu e = Str14
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox22").valu e = Str15
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox21").valu e = Str16
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox17").valu e = Str17
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox18").valu e = Str18
    myItems(i).GetInspector.ModifiedFormPages("P.2").Controls("TextBox19").valu e = Str19

    myItems(i).StartDate = StartDate
    myItems(i).DueDate = DueDate

    myItems(i).Save
    myItems(i).Close (0)
    TaskCount = TaskCount + 1
    End If
    End If
    Next
    End If
    Select Case TaskCount
    Case 0
    MsgBox "No tasks were updated."
    Case 1
    MsgBox "One task was update successfully."
    Case Else
    MsgBox TaskCount & " tasks were updated successfully."
    End Select
    End If
    myItem.Display
    myItem.Save

    X = X + 1
    Loop

    Next

    End Select

    Set objApp = Nothing

    End Sub

  14. #34
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Ims,

    Good-bye and good luck.

    SamT
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  15. #35
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    What I showed basically run the commandbuttton from the Contact....so no answers so it affects all contacts I highlight as the field area does that?

  16. #36
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    And please look at the next question I just posted

Posting Permissions

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