+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Spammer
    Join Date
    02-26-2009
    Location
    India
    MS-Off Ver
    Outlook
    Posts
    98

    Command button is not working by using VBA

    Hi,

    However I designed my first form including a CommandButton which should paste a text into a TextBox (I programmed this function in the VBScript Editor). If I am working in the Developer Mode and click on "Run This Form", the function works properly.

    However if I open the form and directly click on the CommandButton (without
    entering the Developer Mode and clicking Run This Form") or if I send the
    Form, it doesn`t work anymore.

    This is the Code I use:

    Code:
    Sub CommandButton2_Click()
    Dim RequestID
    Dim Tower
    Dim Subject
    Dim Datum
    
    'get control items
    Set RequestID = Item.GetInspector.ModifiedFormPages.Item("Request for
    Change").Controls("RequestID")
    Set Tower = Item.GetInspector.ModifiedFormPages.Item("Request for
    Change").Controls("Tower")
    Set Subject = Item.GetInspector.ModifiedFormPages.Item("Request for
    Change").Controls("Subject")
    Set Datum = Item.GetInspector.ModifiedFormPages.Item("Request for
    Change").Controls("Datum")
    
    RequestID.Value = "DE1-HBM02-IMS-" & Year(Date) & Month(Date) & Day(Date) &
    Hour(Time) & Minute(Time)
    Subject.Value = "Request for Change " & RequestID.Value & " " & "<" &
    Tower.Value & ">"
    Datum.Value = Day(Date) & "." & Month(Date) & "." & Year(Date)
    End Sub
    How can I make the CommandButton work ALWAYS????

  2. #2
    Forum Administrator
    Join Date
    03-18-2009
    Location
    India
    MS-Off Ver
    2003,2007
    Posts
    222

    Re: Command button is not working by using VBA

    Did you publish the form to your Personal Forms library? Code runs only on published forms.
    ExlGuru

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0