Append Function Return Value To Table (1 Viewer)

Dave47

New member
Local time
Today, 09:43
Joined
Aug 18, 2017
Messages
3
I have a button on a form which runs the following code and sends parameters to a VBA function.
I want to append the returned value to a table.
Sounds simple, but I cannot make it work.
HELP!

Dim Value(100) As Integer
Dim HcLoop As Integer

For HcLoop = 0 to 100
ReturnValue(HcLoop) = FunctionName(7, HcLoop, "001002003", "072048024")
‘Append ReturnValue(HcLoop) to a table
?
?
?
Next HcLoop
 

static

Registered User.
Local time
Today, 17:43
Joined
Nov 2, 2015
Messages
823
Your code doesn't make any sense, but anyway

Code:
currentdb.execute "insert into ATable (ANumberField) values (" & TheValue & ")"
 

Dave47

New member
Local time
Today, 09:43
Joined
Aug 18, 2017
Messages
3
Static, thanks for replying.
I have a VBA function in a module which does various calculations based on parameters sent to it via the form VBA behind the button.
The form VBA loops 101 times and the function returns a value for each loop.
I am currently writing these value out to a text file but would prefer to append them to a table.
Hope this make some sort of sense.
 

static

Registered User.
Local time
Today, 17:43
Joined
Nov 2, 2015
Messages
823
Well yeah I got that.
But ReturnValue is not defined. Value is an array. But why are you adding items to an array ifyou are putting them in a table? You just need to store the value.

Code:
Dim HcLoop As Integer
dim myvalue as ??? '< function return type

For HcLoop = 0 to 100
	myvalue = FunctionName(7, HcLoop, "001002003", "072048024")
	currentdb.execute "insert into ATable (ANumberField) values (" & myvalue & ")"
Next

But how are these values that you are adding to this table identified? What is the ID?
For the value to have meaning don't you also need to store the parameters?
 

Dave47

New member
Local time
Today, 09:43
Joined
Aug 18, 2017
Messages
3
Static
Thanks for pointing me in the right direction.
I now have it working.
 

Users who are viewing this thread

Top Bottom