get the value of a "cell"

10 posts / 0 new
Last post
BENOIT
Offline
Joined: 11/29/2018 - 11:25
get the value of a "cell"

Hello,
 
I'm sorry if my question is basic but I would like to know how to get for example the value of the first column and the second line in my Idea's database ?
Thanks in advance !
Benoît

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Benoit,

Nope, nothing basic about this question.  I think this is an advance question as you need to use the RecordSet and Record objects which can be a bit tricky but once you get to know them it is fairly easy.  There is an example in the language browser on how to do it.  What you do is first get the database object, you then use the RecordSet object to get the row that you are interested in.  The final step is to indicate the field that you want to get the record from.  Here is the code, let me know if there is anything that is not clear.


Sub Main

	' Open the database.
	Set db = Client.OpenDatabase("Sample-Detailed Sales.IMD")
	
	' Obtain the RecordSet from the database.
	Set rs = db.RecordSet
	
	' Obtain the tenth record from the RecordSet.
	rs.GetAt(10)
	
	Set rec = rs.ActiveRecord
	' Show that the record holds data.
	MsgBox "INV_NO = " & rec.GetCharValue("INV_NO")
	
	' Clear the memory.
	Set db = Nothing
	Set rs = Nothing
	Set rec = Nothing

End Sub 
Owen Tomme
Offline
Joined: 02/29/2024 - 14:48

Hi Brian,
Is there a way to have this function loop through a database, obtaining not just one specific record, but looping through all records of a database from a specific field?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Owen,

Yes that would be feasable, depending on the size of the file it might be a bit slow.  What are you trying to do as there might be other alternatives.

Owen Tomme
Offline
Joined: 02/29/2024 - 14:48

I am trying to have the script run through a database containing email addresses send Outlook emails to those email addresses.
So far, I have set a global variable in my script for email addresses (emailAddress) and in the function provided in the screenshot, I have the emailAddress variable equal rec.GetCharValue("EMAIL") so that when it moves into the next function, it uses that global variable value to send an email to the email address provided from that database.

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Owen,

You need to add a for loop to read each email address.  Once you have the email then you could use it to call another function that will actually send the email.

BENOIT
Offline
Joined: 11/29/2018 - 11:25

Thanks a lot Brian, it works !

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Thanks for letting me know.

rahulsaxena3
Offline
Joined: 01/09/2018 - 14:02

Hi Brian,
If i want get a cells value & then add it to the preious cell and keep on populating a column like that. Would it be possible ? For eg. in MS Excel, the same formula would like this =
Coln A | Coln B| Coln C|
12               2            
22               4           coln C = 12 + 4 = 16  ----- i.e. -->   A1 + B2 = C2
                                                                                               A2 + B3 = C3
                                                                                                      etc.
in excel it is possible to do this due to cell references. But will i be able to do it in IDEA, which works with columns & not cells ?
 
 

klmi
Offline
Joined: 02/13/2019 - 08:41

Please check the link below:
http://ideascripting.com/forum/counting-last-5-days
Furthermore @GetPreviousValue could help.