set property value from another window

To keep it as simple as possible, I have a desktop project with 2 windows:

The First (wContacts) is a “Document” type window. It displays information about vendors, customers etc. There is a textfield with the contacts email address. Next to it is a bevel button with an Action event that sets 3 public fields in the 2nd window with name, company, and email address:

[code]
wEmail.sEmailAddress = trim(tfEmail1.Text)
wEmail.sCompany = tfCompany.Text
wEmail.sName = trim(tfFirstName.Text) + " " + trim(tfLastName.Text)
wEmail.ShowModal

Return true[/code]

The 2nd window (wEmail) is a “Sheet” type window (I’m on a Mac) with the 3 public string fields declared as string. In the Open event of wEmail I assign 3 textfields to the values of the public string fields:

[code]dim dDate As new Date

GetSMTPServer
GetUser
LoadSignatureMenu
dcDateSent.DateValue = dDate
PopulateUI
tfEmailAddress.Text = sEmailAddress
tfName.Text = sName
tfCompany.Text = sCompany

Return[/code]

I placed a trace point at the 1st line of code in the action event of the bevel button and examined the textfields and they all contained the correct information.

BUT, when the wEmail window opens, the string fields are empty

I’m on a Mac Pro with macOS 10.11.1 and Xojo v2017r1.1

So, what am I missing - besides sitting here writing code at 7:00 on a Friday night…

If the variables are assigned in the first window (w.Contacts) then you call them when you open the second window (wEmail):

tfName.Text = w.Contacts.sName

It looks like you are assigning variables to a window that’s not opened yet, ie.

wEmail.sName = trim(tfFirstName.Text) + " " + trim(tfLastName.Text)

Unless I misunderstand what you are saying.

The Open event of an implicit instance can happen as early as you touch the window the first time, ie the line you’re setting wEmail.sEmailAddress. Your code then proceeds to set variables, and then show the modal (if it’s a Sheet, why are you not using ShowModalWithin?), but not set the variables to the interface because Open has already happened.

You may have more success with a method on the sheet window that handles the setting / display, something like:

[code]Sub Display(sName as String, sEmail as String, sCompany as String, winParent as Window)
GetSMTPServer
GetUser
LoadSignatureMenu
PopulateUI

dcDateSent.DateValue = new Date

txtName.text = sName
txtEmail.text = sEmail
txtCompany.text = sCompany

self.ShowModalWithin(winParent)
End Sub
[/code]

On the parent window you would then:

dim wDetails as new winDetails wDetails.Display("John Doe", "john@doe.org", "Company, Inc.", self)

thanks to both of you folks. I just didn’t quite understand WHEN the open event occurred.