Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: Dynamicly changing a control
Paul Hutchison
Posts: 30
 
Dynamicly changing a controlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Aug 09 10:49 AM
I am trying to dynamically set the properties of various controls on a form, I have enabled / disabled controls in the past, and am now using this knowledge to make things even slicker...

I am using Controls(ControlName).Visible / Left / Top / Width / Height with no problem.

What I am having trouble with is linking the control to a field in the database. when you change a control in Architect, you change the 'Text' property to define which field from the database it displays/updates when changed, but using Controls(ControlName).Text just puts the text you specify (e.g. "USERNAME") into the control rather than linking to the USERNAME field in the database.

I have figured out that for PickLists I have to put Controls(ControlName).PickListName.Name, so am guessing I need to do something similar?

This might seem like an odd thing to do, but basically I have a form which had 200+ controls on it as it was used for several purposes, Needless to say it was quite slow to load, so I am trying to use 70 controls, and change their function dependant on the needs of the form (if that makes sense!).

Any help would be greatly appreciated.
Paul.
[Reply][Quote]
Mike Spragg
Posts: 1226
Top 10 forum poster: 1226 posts
 
Re: Dynamicly changing a controlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Aug 09 3:13 AM
Paul

I think this is what you need:

============================
Dynamic Objects/VariableName
============================

> For T = 1 to 58
> Execute "A" & T & ".Enabled = True"
> Next

Regards
Mike
[Reply][Quote]
Paul Hutchison
Posts: 30
 
Re: Dynamicly changing a controlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Aug 09 5:29 AM
Mike,

Sorry, but I'm not sure how that works, it looks to be enabling the controls, but I have already done that?

I'm wanting to set the field in the database that the control displays / updates. If that's what this does could you explain a bit further?

Thanks,
Paul.

[Reply][Quote]
Carla Tillman
Posts: 290
 
Re: Dynamicly changing a controlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Aug 09 9:16 AM
Paul,

You want to dynamically bind the data field to the control? If so, it may be easier to go with non-binding fields and handle the field updates with a series of IF/And or Selects ot Switches from the OnValidate or Save functions. (Not sure what version or Lan v Web you are discussing)
Handling disconnected RecordSets is also a possible option.

On Validate

IF MyFlagField =True
Update MyTable
set myValue = Textbox1.Text
Where ....
ELSE
Update Table2
set Value2 = Textbox1.Text
Where ....
END

Carla






[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Dynamicly changing a controlYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Aug 09 9:51 AM
Older versions of the Controls contained a DataPath property, the current version contain a hidden "DymmyDataPaths" I believe is the replacement of the DataPath (but probably just used for the Display on Design mode), and also has a DataBindings Property (also hidden) which is probably where the actual binding is configured.

That being said, I believe that you need to reconsider this approach.

The best approach is to develop a distinct form for each "purpose". So, if you have 5 needs for this form, create 5 forms, and before displaying them add a step to allow the user to select what they are doing so you could display the correct form.
By doing so, each form will only have the necessary fields, and you could use full advantage of the Design time binding. Also, it will eliminate a lot of the code in place needed to figure out what fields to display and what data to write (and where).



The second best approach, as suggested by Carla, would be to make all the fields that could have multiple purposes unbound fields, then have hidden fields to write the data accordignly.
For example, a text box called txtBoxA1 can write to three DB fields depending on the selections made on other fields. Thus, my text box is unbound, but I have 3 hidden Text boxes bound to the appropriate fields: txtBoxField1, txtBoxField2 and txtBoxField3.

So, the If statement would go somehting like this:
If condition1 = true then
txtBoxField1 = txtBoxA1
else if condition2 = true then
txtBoxField2 = txtBoxA1
else if condition3 = true then
txtBoxField3 = txtBoxA1
End If
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/26/2024 9:50:12 AM