form for text input

Ok,

In my code, when an item is not found in the database, the program asks the user if they would like to add it. If the answer is yes, the program is to display a form to add the item. BUT, the program continues processing instead of waiting for the form to be displayed and the data entered… the code is below:

    If Response = 6 Then
      frmTinput.Title = "New Asset Description"
      frmTinput.lblItem.Text = "Please Enter an Asset Description / Name"
      frmTInput.Show
      TDESC=Globals.uinput
      frmTinput.Title = "New Asset Type"
      frmTinput.lblItem.Text = "Please Enter the Asset Type"
      frmTInput.Show
      TTYPE = Globals.uinput
      strSQL = "Insert INTO SECLIST (ticker, asset_name, Type) VALUES ('" + TTICK + "','" + TDESC + "',"+ tType + "')"
      data.SQLExecute(strSQL)
    End If

How do I get the program to wait until the form is loaded, data entered, and the form is closed??

Thanks

This is a desktop app, I presume? Make your form window modal and call it with ShowModal.

For more information, check out User Guide Book 2: User Interface, Chapter 2: Desktop, Section 13.3: Using a Window as a Dialog Box.

Thanks Paul, I will try that…

I can’t get this to work. I’ve got a button that gets data from a database based on user input. A window is opened, text box for input, property get set, OK button closes window, and the the db lookup occurs. Problem is that the code is not waiting for the user to input to complete. It just blows right by it.

What is your code? Are you displaying the window using ShowModal?

ummm…nope. That’ll do it. Thanks.

I’m also not doing something right with the window property. I’ve got a property named TextReturned, a textbox named TextInput, and a button that when clicked does:

TextReturned=txtTextInput.Text Self.Close

Then in the “main” window I try to get the value of that property and put it in the variable vTextReturned:

vTextReturned=winGetTextInput.TextReturned

I’m not following the example on the page too well. (page 94 in Acrobat)

TextReturned is being destroyed when you’re closing the modal. You’ll need to pass it out of the modal before trying to get it with the main window, or get it with the main window before you close the modal. If you have the main window waiting I would pass it out to a global variable.

Create a new public method in the window which returns a string. Call the method something like ShowMe.

In this method open the window itself with

self.ShowModal

After that line return the text field value

Return TextReturned

Then in the calling window

myTextReturn = WinGetTextInput.ShowMe

[quote=80872:@Duane Mitchell]I’m also not doing something right with the window property. I’ve got a property named TextReturned, a textbox named TextInput, and a button that when clicked does:

TextReturned=txtTextInput.Text Self.Close

Then in the “main” window I try to get the value of that property and put it in the variable vTextReturned:

vTextReturned=winGetTextInput.TextReturned

I’m not following the example on the page too well. (page 94 in Acrobat)[/quote]
Are you creating the window with New? Eg.,

winGetTextInput = new xxxx

Or is that the name of the window and you’re using implicit instantiation? If winGetTextInput is the name of the window in the navigator, then your code should be

dim w as New winGetTextInput
w,ShowModal
vTextReturned = w.TextReturned

Otherwise, winGetTextInput is completely destroyed upon Close (since there are no other references to it) and vTextReturned = winGetTextInput.TextReturned causes a new, fresh version of the window to be created - instantiated implicitly. If you dim your own reference to the window, then the window’s properties remain intact after the window is closed. All the controls will be destroyed (unless you hold a reference to them too), but the properties are still available.

OK, that’s what the problem was. I created a new property on the calling window and it all works. Thanks for the suggestions and clarifications. I don’t understand properties very well. But better now.