Select to view content in your preferred language

More VBS help....please

616
2
Jump to solution
06-29-2012 02:07 PM
CamKenny
Emerging Contributor
I recieved some code from an earlier post - and it has helped me a great deal.  I am not new to vb, but the new method of working with AXF's and related tables has me somewhat perplexed.

Option Explicit  Sub getAllControls()     'get the Form object     Dim objForm     'ThisEvent access the object based on the event that was executed     Set objForm =  ThisEvent.Object 'or you could use something like this: Map.Layers("Poles").Forms("EDITFORM")       Dim objEditPage      Set objEditPage = objForm.Pages("General")     Dim objAllControls     Set objAllControls = objEditPage.Controls       Dim objControl     for each objControl in objAllControls         'Creates an application variable which can be used anywhere in ArcPad.         Application.UserProperties(objControl.Name) = objControl.Value         Console.print Application.UserProperties(objControl.Name)     next End Sub  'This would set on the tableform onload event Sub AccessTheUserProperties()     Dim objTableForm     Set objTableForm = ThisEvent.Object      Dim objTablePage = objTableForm.Pages("Lights")     Dim objtxtBox     Set objTxtBox.Text = Application.UserProperties("domMaterial") End Sub


Lets assume that I have a txtBox ("txtAppl") that contains the intial applicant number stored in the editform for the feature class.  I also have a tableform (related table) that also contains a txtBox ("txtAppl") that is empty and want to populate based on the editform "txtAppl" control.

I believe I have set the code up correctly as pointed out, but for some reason, when I get to the "Dim objtxtBox" and "set objtxtBox.Text".  The application user properties "txtAppl" throws an error.  I believe it is actually throwing the error at the objTxtBox.Text portion.

If someone could explain the flow of the script, it would be greatfully appreciative.

Here is the script I have generated based on Gareth's post:

Option Explicit  Dim pApplicantsDataForm Dim pApplicantsDataControls Dim pTreesTableForm Dim pTreesDataBaseControls Dim pFieldDataTableForm Dim pFieldDataBasePage Dim pFieldDataBaseControls Dim pFieldDataSiteControls Dim pFieldDataTreeControls  Sub InitializeDataCollection()   Set pApplicantsDataForm = ThisEvent.Object  Set pApplicantsDataControls = pApplicantsDataForm.Pages("page1").Controls   Dim objApplicantsDataControls  for each objApplicantsDataControls in pApplicantsDataControls   Application.UserProperties(objApplicantsDataControls.Name) = objApplicantsDataControls.Value   Console.print Application.UserProperties(objApplicantsDataControls.Name)  next  End Sub  Sub InitializeFieldDataTableForm()  Set pFieldDataTableForm = ThisEvent.Object  Set pFieldDataBasePage = pFieldDataTableForm.Pages("page1")   Set pFieldDataBaseControls = pFieldDataTableForm.Pages("page1").Controls   Dim txtAppl  Set txtAppl.Text = Application.UserProperties("txtAppl") End Sub
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GarethWalters
Deactivated User
Hi Cam,

I gave you a bum steer I am afraid. I forgot to initialise the txtBox object then set the value.

Sub AccessTheUserProperties() Dim objTableForm  Set objTableForm = ThisEvent.Object  Dim objTablePage  Set objTablePage = objTableForm.Pages("Lights")  Dim objtxtBox  Set objTxtBox = objTablePage.Controls("txtTest")  objTxtBox.Text = Application.UserProperties("domMATERIAL") End Sub

View solution in original post

0 Kudos
2 Replies
GarethWalters
Deactivated User
Hi Cam,

Try changing it to txtAppl.Value.

Let us know how you go.
0 Kudos
GarethWalters
Deactivated User
Hi Cam,

I gave you a bum steer I am afraid. I forgot to initialise the txtBox object then set the value.

Sub AccessTheUserProperties() Dim objTableForm  Set objTableForm = ThisEvent.Object  Dim objTablePage  Set objTablePage = objTableForm.Pages("Lights")  Dim objtxtBox  Set objTxtBox = objTablePage.Controls("txtTest")  objTxtBox.Text = Application.UserProperties("domMATERIAL") End Sub
0 Kudos