Code to open screen


  • Hi,

    Basically what i want to do is have a button that i can click that will allow me to open a "New Data Screen". I want the button to be in the top command bar though. Any way i can do this?

    Monday, March 21, 2011 2:40 AM

All replies

  • Hi Brendan,

    The following lesson in the Guided Tour shows how to create a Shell command that launces a screen: http://msdn.microsoft.com/en-us/library/ff852049.aspx

    The example uses a parameter from a search sceen to display a details screen, but you could easily modify it to launc a New Data Screen.

    Hope this helps,

    Steve Hoag Microsoft aka the V-Bee
    Monday, March 21, 2011 3:09 AM
  • Hi Steve,

    Already worked out how to do it, well to some extent. It opens the new screen but i would like it a popup dialogue. Not sure if i can do that though.

    Monday, March 21, 2011 4:02 AM
  • In the screen designer, create a Button, then add the following code,


    Here Customers is  the name of the table to which you want to add data.

    • Proposed as answer by Erik - MSFT Monday, March 21, 2011 5:53 PM
    • Unproposed as answer by Brendan Thompson Thursday, March 24, 2011 10:59 PM
    Monday, March 21, 2011 5:51 PM
  • Yaqi,


    This doesnt work AddAndEditNew() doesnt exist? Am i missing a reference?

    OK im using Projects as my table that the first screen is accessing. I want my button to add a Note, Notes are in a seperate table and have a zero or one relationship with the projects table

    Tuesday, March 22, 2011 5:37 AM
  • Add the button in the screen designer.  Then right click on the button and select the execute code method.  In the execute code method type application.ShowNewNoteScreen   or whatever the screen you want to show is called.  It will be something like ShowNotesScreen.
    • Proposed as answer by Gberg Tuesday, March 22, 2011 6:50 AM
    Tuesday, March 22, 2011 6:50 AM
  • AddAndEditNew() did not exist because the table is not one of the data sources for the screen.

    First, you need to add your Notes table to the Project screen through Add Data Item at the top of the screen deisgner.

    Second, use this following code to add a new Note and bring up the modal dialog,

             partial void Method_Execute()
                // Create a new note and attach it to the current project
                Note note = Notes.AddNew();
                note.ProjectsItem = Projects.SelectedItem;

    Wednesday, March 23, 2011 6:54 PM