Public Sub pgComposer_tblContacts_Create(page As ndxContainer)
Dim clientPK As String: clientPK = page.Parent.Field("dfClientPk").StrValue
Dim nSQL As ndxSQL: Set nSQL = page.Session.Database.Connect
Dim sSQL As String: sSQL = "select Name, Email from Contact where client_fk=" & clientPK
'MsgBox clientPK
If nSQL.Prepare(sSQL) = ndTrue Then
If nSQL.Execute = ndTrue Then
'return only the first result entery
nSQL.FetchFirst
Dim i As Integer
For i = 1 To nSQL.RowCount
page.Row = i
With page.Field("txName")
.Title = "Name"
'.StrValue = nSQL.StrValue(0)
.Default = nSQL.StrValue(0)
End With
With page.Field("txAddress")
.Title = "Address"
'.StrValue = nSQL.StrValue(1)
.Default = nSQL.StrValue(1)
End With
nSQL.FetchNext
Next
Else 'if there is a problem executing
nSQL.Rollback
End If
Else ' if there is a problem preparing
nSQL.Rollback
End If
End Sub