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 - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Counting controls on a form
RJ Eaton
Posts: 234
 
Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 9:57 AM
fiogf49gjkf0d
anyone have a hint how I can count the number of controls on a form. I would like to loop through them setting certain fields based on conditions, better than going and typing everysingle one

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 12:32 PM
fiogf49gjkf0d
This should answer your question:

http://saleslogixblog.com/rfarley/archive/2004/07/26/925.aspx

[Reply][Quote]
RJ Eaton
Posts: 234
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 12:45 PM
fiogf49gjkf0d
Thanks Ryan was what I was looking for..
[Reply][Quote]
RJ Eaton
Posts: 234
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 1:49 PM
fiogf49gjkf0d
Ryan,

Getting an error about needing an Object in this piece of code.. am I missing something..

*********** CODE *********************
Dim i, frm, cName, z

For i = 0 to Application.Forms.Count - 1
If Application.Forms(i).Name = "frmGCSDistributions" Then
Set frm = Application.Forms(i)
For z = 0 to frm.ControlCount - 1

If frm.Controls(z).Parent.Name = "pnlBetaTop" Then 'Clean the form
cName = frm.Controls(z).Name
If Instr(1, Left(cName,3), "pkl") or Instr(1, Left(cName,2), "ed") or Instr(1, Left(cName,2), "cb") Then
cName.Text = ""
End If

Else
If frm.Controls(z).Parent.Name = "pnlBetaBottom" Then
cName = frm.Controls(z).Name
If Instr(1, Left(cName,3), "pkl") or Instr(1, Left(cName,2), "ed") or Instr(1, Left(cName,2), "cb") Then
Set cName.Text = ""
End If
End If
End If
Next
End If
Next

Thanks

Rich
[Reply][Quote]
RJ Eaton
Posts: 234
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 2:14 PM
fiogf49gjkf0d
Actual Error is:

Microsoft VBScript runtime error: Object required: 'cName'
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 Aug 06 2:32 PM
fiogf49gjkf0d
Quote:
Originally posted by RJ Eaton

Set cName.Text = ""

Change it to just cName.Text in your Else statement. The set threw it off.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 2:06 PM
fiogf49gjkf0d
Also, if you're on 6.1 or higher, you don't have to loop through the forms collection any more. You can do this now:

Set frm = Application.Forms["System:MyForm"]


Originally, that didn't work (when I wrote the article on this site). But as of 6.1 it was fixed.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 5:01 PM
fiogf49gjkf0d
I place a "dim oAXForm" outside of any method in the script then in the OnCreate event I call "set oAXForm = Sender". Then its oAXForm.Whatever for the life of the form. I do this for literally every form customization I've had since 6.1. I had a habit in the beginning of naming my forms incorrectly and this saved my butt at the time.

I don't claim ownership of the technique. I got it from the ITToolbox discussion group which probably got it from somewhere else, like the BP newsgroup.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 5:26 PM
fiogf49gjkf0d
I dont like this approach because you lose intellisense. For this same reason I also dislike how the stock product does

set oBF = Application.BasicFunctions (or something similar)

It is challenging enough as it is working in VBScript. I will take any intellisense I can get.

Timmus
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 5:41 PM
fiogf49gjkf0d
There's that late binding crap again.

I'd be content with AXForm or some kind of keyword that points to the form the script is tied to. We have Form.Script which links to the script but there is no Form property linking from the script back. That would solve the intellisense problem, and keep me from doing the set oAXForm = Sender every time.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 5:49 PM
fiogf49gjkf0d
I agree. Having a "me" or "this" or whatever that references the current form would be nice.

Timmus
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 5:57 PM
fiogf49gjkf0d
I guess I am missing something. When I need to reference controls on a form, properties of the form, script subs & functions tied to the form (talking current form here), I just use the form name (or omit it altoghether)

ie:

If my form's name is "MyForm", then you could access things on the form like this (with intellisense)
val = MyForm.Edit1.Text
MyForm.Caption = "New caption"
MyForm.Scripts.SomeSub ' redundant since you could just call SomeSub directly


You can also omit the form name completely
val = Edit1.Text
Caption = "New caption"
Scripts.SomeSub ' redundant since you could just call SomeSub directly


The form name is your "this" or "Me".

You can use it to pass a form reference to some other script too (to save the need to grab it from the forms collection)
Set cls = New SomeClass
Set cls.Form = MyForm
cls.DoSomething


So, what am I missing from this conversation?
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 6:00 PM
fiogf49gjkf0d
Correct, but it would be nice to have generic code that doesnt have to know the current form name. Not a big deal by any means.

Timmus
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 6:07 PM
fiogf49gjkf0d
Epiphany: I am going to rename all the forms in the system to "me".
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Aug 06 6:16 PM
fiogf49gjkf0d
Quote:
Originally posted by Timmus Agersea

Epiphany: I am going to rename all the forms in the system to "me".


Hehe. That is great.
[Reply][Quote]
Todd Hardin
Posts: 43
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Aug 06 11:10 AM
fiogf49gjkf0d
re: dim oAXForm
That was my invention in SLX v6.0/v6.1 days. Ryan Farley, myself and others were frustrated with the lack of a "me" or "this" reference and this was a compromise. I don't use this as religiously as I used to... not sure why.

[Reply][Quote]
Bob (RJ)Ledger
Posts: 1103
Top 10 forum poster: 1103 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 06 1:27 PM
fiogf49gjkf0d
Quote:
Originally posted by Timmus Agersea

Epiphany: I am going to rename all the forms in the system to "me".


Humm.. now if you do that.. how do we tell one form from another?
--
rjl
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 06 1:35 PM
fiogf49gjkf0d
Quote:
Originally posted by Bob (RJ)Ledger



Humm.. now if you do that.. how do we tell one form from another?
--
rjl


By plugin name.
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 06 4:50 PM
fiogf49gjkf0d
I was thinking about making each form's background color unique. Once I run out of colors I will just have to tell the customer that they exceeded the supported number of forms.

Timmus
[Reply][Quote]
Matt Edenhofer
Posts: 2
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 06 5:15 PM
fiogf49gjkf0d
Unfortunately for your idea, you would still be able to create over 16 million forms since you can put this code in the form load event.

form.color = rgb(0,0,0)
thru
form.color = rgb(255,255,255)
[Reply][Quote]
Timmus Agersea
Posts: 328
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 06 5:24 PM
fiogf49gjkf0d
I am way too lazy for that. I will only support the colors in the properties pane drop down.

Timmus
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Counting controls on a formYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 06 6:54 PM
fiogf49gjkf0d
I'd just place a routine that keeps the form from staying open if one with a similar name is present in the Forms collection. That way when SalesLogix goes to cache the form it'll see that one is already present, making sure users will only have access to one screen of one customization at any given time until they log back in (since Ctrl-F5 or F5 will refresh the cache).

A typical tech support call:
"When I go to click on X a screen pops up then mysteriously closes every time, what gives?"
"We have placed a usage restriction on your screens so that you can only do one thing at a given time because SalesLogix is a man. You can pay extra for the extended 'Put on a pretty dress' package that only costs an additional $199 per user to give you all of the functionality you want."
"Does this mean I'm a little girl?"
"Yep. Thank you sir and have a nice day!"
[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 8:46:48 AM