I am trying to read the value from a form that is opened. I can get the value if i call the subroutine from the form that has the control doing the following
Form = Drawpage.Forms.getByName(“MyForm”)
But i am trying to get the value when in another form. When I do the following:
Form = ThisDataBaseDocument.getformdocuments.getByName(“TheTextBox”)
I get a noSuchElementException error even if i run it from the form the text box is on
I made a typeo, the (“TheTextBox”) should read (“MyForm”)
Form = ThisDataBaseDocument.getformdocuments.getByName(“MyForm”)
Note:
- There are form documents. You form document has name “MyForm” when you open the database file and switch to forms.
- There are forms on the drawpage of the form document and inside this forms there are controls. If you want to get a value of a control you have to look for the form on the drawpage inside the form document.
Might be something like this:
ThisDatabaseDocument.FormDocuments.getByName("MyForm").Drawpage.Forms.getByName("MainForm").getByName("Textfield")
… but the form document has to be opened first so you first get the document and then get the form inside this document:
oDoc = ThisDatabaseDocument.FormDocuments.getByName("MyForm").open
stText = oDoc.Drawpage.Forms.getByName("MainForm").getByName("Textfield")
Another form = FCaller
Opened Form with the textbox TextBox1 = FTextBox > Main
Option Explicit
Sub LerTB(Evt As Object)
Dim Frames As Object, F As Object, FMain As Object
Dim chk_forms As String
Dim i As Integer
On Error GoTo Erro
REM CHECK TARGET FORM IS OPEN
Frames = ThisDatabaseDocument.getCurrentController().getFrame().getFrames()
For i = 0 To Frames.count - 1
F = Frames.getByIndex(i)
chk_forms = Mid(F.title, Instr(F.title, ":") + 2)
chk_forms = Trim(Left(chk_forms, Instr(chk_forms, " - Libre")))
If chk_forms = "FTextBox" Then Exit For
Next i
If chk_forms <> "FTextBox" Then Exit Sub
REM IT IS OPEN:
F = ThisDatabaseDocument.FormDocuments.getByName(chk_forms)
FMain = F.getComponent().getDrawPage().getForms().getByIndex(0)
print FMain.TextBox1.Text
Exit Sub
Erro: MsgBox "ERRO " & Err & Chr(10) & "na linha " & Erl
End Sub
Thanks Guys

