How do you get A5 to accept as a form name the value from a field in a table?
I have created a new form with only one A5V9 pushbutton control, which executes the code below:
When the button is clicked, the following error message is received:
While the above simply demonstrates what appears to me to be a fairly serious problem, the code below shows all the approaches I have attempted to get A5V9 to dynamically open a form based on a value in table, not "hardwiring" it in code.
Here's my "real" code, and the question boils down to how to get AlphaFive to think its dealing with a form name that must be in quotes. I even tried changing the table field value from frmA to "frmA", that is putting " " around the value, and it failed.
Two days ago, I reported success in creating an hierarchical menu using a third party Tree control. I have worked through all the issues with that control, and was actually feeling quite good about having accomplished something non-trivial with A5, but just as I was ready to post my code to the code library, I hit what hopefully is not a fatal bump.
MS Access has no problems opening a form based on the value of a variable. Does anyone have any suggestions on what workaround might allow A5V9 to do this also?
Thanks,
Bob
Pittsburgh
I have created a new form with only one A5V9 pushbutton control, which executes the code below:
Code:
tbl = table.open("tblMenu") tbl.fetch_first() Dim mSelectedForm As C mSelectedForm = tbl.FORM_ID msgbox(mSelectedForm) 'msgbox displays: frmA f=form.load(mSelectedForm) f.show() f.activate()
Code:
Error: OnPush line: 14 f=form.load(mSelectedForm) Object does not support requested interface
Here's my "real" code, and the question boils down to how to get AlphaFive to think its dealing with a form name that must be in quotes. I even tried changing the table field value from frmA to "frmA", that is putting " " around the value, and it failed.
Code:
If doIt then Dim mSelectedForm As C Dim mSelectedNode As N mSelectedNode = ctTree1.Selected() msgbox("Selected node "+str(mSelectedNode)) mSelectedForm = ctTree1.NodeCargo(mSelectedNode) msgbox(mSelectedForm) 'The message box correctly displays: frmA 'Case 1: This works 'f=form.load("frmA") 'Case 2: This works 'mSelectedForm = "frmB" 'f=form.load(mSelectedForm) 'Case 3: This does NOT work 'mSelectedForm = """ + mSelectedForm + """ 'msgbox(mSelectedForm) 'here's what the message box displays: + mSelectedForm + 'f=form.load(mSelectedForm) 'Case 4: This does NOT work 'mSelectedForm = '"' + mSelectedForm + '"' 'This fails the code syntax check as an empty expression 'msgbox(mSelectedForm) 'f=form.load(mSelectedForm) 'Case 5: This does NOT work 'mSelectedForm = "'" + mSelectedForm + "'" 'This fails the code syntax check as missing or invalid keyword 'msgbox(mSelectedForm) 'f=form.load(mSelectedForm) f.show() f.activate() doIt=.f. end if
MS Access has no problems opening a form based on the value of a variable. Does anyone have any suggestions on what workaround might allow A5V9 to do this also?
Thanks,
Bob
Pittsburgh
Comment