Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, August 23, 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: Adding multiple records
Bill
Posts: 71
 
Adding multiple records Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 May 08 3:00 PM
I have a Tab control with text fields on the first tab, the second tab has a split screen with a treeview on one side and a datagrid on the other side. The third tab is this way also. On the last tab the data is displayed in three different grids. I am using a managed form and I am able to update the database with the first record from each grid. The code updates one table using the data from one grid. This is the code I am using:

Set objRS = CreateObject("ADODB.Recordset")
With objRS
Set .ActiveConnection = Application.GetNewConnection
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "SELECT * FROM TR_Attendee_Fee WHERE 1=2"

.AddNew
.Fields("TR_Attendee_FeeID").Value = Application.BasicFunctions.GetIDFor("TR_Attendee_Fee")
.Fields("TR_Class_AttendeeID").Value = strClassAttendeeId
.Fields("TR_ClassID").Value = strClassId
.Fields("CREATEUSER").Value = Application.BasicFunctions.CurrentUserID
.Fields("CREATEDATE").Value = Now
.Fields("MODIFYUSER").Value = Application.BasicFunctions.CurrentUserID
.Fields("MODIFYDATE").Value = Now
.Fields("Actual_Amount").Value = dgAttendeeFees.GetCurrentField("Amount")
.Fields("TR_Course_FeeID").Value = dgAttendeeFees.GetCurrentField("tr_course_feeid")
.Update
.Close
End With
Set objRS = nothing

This update is the second of four that execute. It needs to add a new record to the database for every record the grid on the treeview contains. Any ideas on the syntax to get this to loop? Everything I tried failed.

Thanks......
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Adding multiple records Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 May 08 9:55 AM
Loop through what? the Grid's recordset? The Nodes on the Tree view?

SET rsDG = GridName.RECORDSET
WHILE NOT rsDG.EOF
strClassAttendeeId = gridname.GetcurrentField(""ClassAttendeeId) ''get the ID field value and then call your insert routine
rsDG.MOVENEXT
WEND

kinds of stuff.....

or
FOR I = 0 to rs.RecordSet.Count - 1

NEXT

MUST DO!
grid.REFRESH on all of these grids that you add records to...after you've inserted the rows in the database!!!
So what have you tried for a looping structure?

Desireable: If you are in 7.x+ don't worry about the Create, Modify fields....let the provider handle that. (also AutoIncrement possible on the ID field....)
[Reply][Quote]
Ron Buchanan
Posts: 72
 
Re: Adding multiple records Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 May 08 3:29 PM
RJ,
How do we determine if one of these rows is selected while we're cycling through the records?
[Reply][Quote]
Ron Buchanan
Posts: 72
 
Re: Adding multiple records Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 May 08 3:51 PM
Never mind... found it here: http://www.slxdeveloper.com/forum.aspx?forumid=2000&postid=13110#13110

Thanks Ryan!
[Reply][Quote]
Bill
Posts: 71
 
Re: Adding multiple records Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 May 08 8:39 AM
I figured it out, after I deleted the code I tried for my loop I started putting it back in and ended up using this:

Set objRS = CreateObject("ADODB.Recordset")
Set objRS2 = dgAttendeeFees.Recordset
With objRS
Set .ActiveConnection = Application.GetNewConnection
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "SELECT * FROM TR_Attendee_Fee WHERE 1=2"
with objRS2
if not (.BOF and .EOF) then
intCount = .RecordCount
objRS2.MoveFirst
for i = 0 to .RecordCount - 1
objRS.AddNew
objRS.Fields("TR_Attendee_FeeID").Value = Application.BasicFunctions.GetIDFor("TR_Attendee_Fee")
objRS.Fields("TR_Class_AttendeeID").Value = strClassAttendeeId
objRS.Fields("TR_ClassID").Value = strClassId
objRS.Fields("CREATEUSER").Value = Application.BasicFunctions.CurrentUserID
objRS.Fields("CREATEDATE").Value = Now
objRS.Fields("MODIFYUSER").Value = Application.BasicFunctions.CurrentUserID
objRS.Fields("MODIFYDATE").Value = Now
objRS.Fields("Actual_Amount").Value = objRS2.Fields("Amount").Value
objRS.Fields("TR_Course_FeeID").Value = objRS2.Fields("TR_Course_FeeID").Value
objRS.Update
objRS2.MoveNext
next
objRS.Close
End if
End With
end With
Set objRS = nothing
Set objRS2 = nothing
[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/23/2025 6:03:42 PM