Skip to main content

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 Sat, 12/15/2018 - 13:46

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 Thu, 02/29/2024 - 16:35

In reply to by Brian Element

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 Thu, 02/29/2024 - 18:50

In reply to by Owen Tomme

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 Fri, 03/01/2024 - 09:08

In reply to by Brian Element

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.

Brian Element Fri, 03/01/2024 - 10:03

In reply to by Owen Tomme

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.

rahulsaxena3 Fri, 09/18/2020 - 07:56

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 ?