Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, August 24, 2025 
 
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: Add GetField result to a ComboBox
Paul Hutchison
Posts: 30
 
Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Aug 08 6:55 PM
Hi,

I appologise in advance if this is a simple question - I just can't get my head around it!!

I am using the following to determine the Contract number that an Asset is associated with:

ContrID = GetField("CONTRACTID", "ContractItem", "ACCOUNTPRODUCTID='" & AccProdId & "'")

However an Asset can be associated with more than one Contract, so I decided to use a ComboBox (space is at a premium), but I cannot figure out how to add each of the Contracts the Asset is associated with to the COmboBox.

Perhaps GetField is not the correct command to use (as it seems to just return the first match), any suggestions?
[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 3:35 AM
Hi Paul,

You could use GetFields to get the list of Contract Numbers.

You will then need to check GetFields returned something, GetFields fills the array you pass it so you will need to work out the length, step though the array and add the items to the combo.

Cheers,

Steve
[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 3:45 AM
Hi Paul,

You may find using a recordset easier.

Cheers,

Steve
[Reply][Quote]
Paul Hutchison
Posts: 30
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 7:22 AM
Steve,

Thanks for the info & suggestions, the trouble is that I'm okay with VB, but the database side of it is what i'm having trouble with!

I wasn't aware that GetFields returned an array of values, I thought it was just returning one.

If you could give me an example of the code to step through the array I'd appreciate it.

Thanks,
Paul.
[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 7:48 AM
Hi Paul,

There are 2 functions in the SLX Database Support script:

GetField(strField, strTable, strWhere)

GetFields(strField, strTable, strWhere, strValue)

GetField does return one record, GetFields returns the array but for one record so you will need use the record set approach.

Cheers,

Steve
[Reply][Quote]
Paul Hutchison
Posts: 30
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 7:51 AM
Ah,

I hadn't eealised there was a GetField & GetFields, btu as you say neither will do what I am after.

Can you give me an example of using the Record Set approach?

Thanks,
Paul.
[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 8:13 AM
Hi Paul,

The following should help - this takes your AccProdId (I haven't validated it contains data) and populates a combo control called cboTest.


Dim objRS
Dim strSQL
Dim i

Set objRS = CreateObject("ADODB.Recordset")
Set objRS.ActiveConnection = Application.GetNewConnection
If ErrorCheck(Application.Translator.Localize("Error getting new connection.")) Then Exit Sub
objRS.CursorLocation = adUseClient
objRS.LockType = adLockBatchOptimistic
objRS.CursorType = adOpenStatic
strSQL = "SELECT CONTRACTID FROM CONTRACTITEM WHERE ACCOUNTPRODUCTID='" & AccProdId & "'"
objRS.Open strSQL

If Not (objRS.BOF and objRS.EOF) Then
objRS.MoveFirst
cboTest.Items.Clear
For i = 0 to objRS.RecordCount - 1
cboTest.Items.Add objRS.Fields("CONTRACTID").Value
objRS.MoveNext
Next
End If

objRS.Close
Set objRS = Nothing
<\Pre>

Hope this helps,

Steve
[Reply][Quote]
Steve Robertson
Posts: 146
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 8:31 AM
Hi Paul,

Sorry spotted an error in clearing the combo:


Dim objRS
Dim strSQL
Dim i

Set objRS = CreateObject("ADODB.Recordset")
Set objRS.ActiveConnection = Application.GetNewConnection
If ErrorCheck(Application.Translator.Localize("Error getting new connection.")) Then Exit Sub
objRS.CursorLocation = adUseClient
objRS.LockType = adLockBatchOptimistic
objRS.CursorType = adOpenStatic

strSQL = "SELECT CONTRACTID FROM CONTRACTITEM WHERE ACCOUNTPRODUCTID='" & AccProdId & "'"
objRS.Open strSQL

If Not (objRS.BOF and objRS.EOF) Then
objRS.MoveFirst
If cboTest.Items.Count <> 0 Then
cboTest.Items.Clear
cboTest.Text = ""
End If

For i = 0 to objRS.RecordCount - 1
cboTest.Items.Add objRS.Fields("CONTRACTID").Value
objRS.MoveNext
Next
End If

objRS.Close
Set objRS = Nothing



Cheers,

Steve
[Reply][Quote]
Paul Hutchison
Posts: 30
 
Re: Add GetField result to a ComboBoxYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 07 Aug 08 9:52 AM
Steve,

thanks for this, It's way more complicated than I had expected, so I very much appreciate the assistance.

I have got it working now, so on with the next challenge!

Regards,
Paul.
[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 © 2025 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): 8/24/2025 6:24:33 PM