MS-Access-97 sending global variables to MultiCharts works.

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Guest

MS-Access-97 sending global variables to MultiCharts works.

Postby Guest » 24 Aug 2007

Originally this email came from a different email list.
It may be of interest to those who program MS-Access or
any VBA code or visual basic generally.

This was the original subject.
(Suggestion worked) Sending a Global Variable from MS-Access-97 to a very simple system is failing.


Thanks guys.

For any interested, the suggestions worked to solve the problem.
Specifically I changed the integer definitions in MS-Access-97 to long definitions.
I included the new MS-Access-97 code at the very bottom.
It is highlighted like this.

=======================================================
MS-Access Code that worked when integer definitions
were changed to long definitions.
=======================================================


Thanks again,
John.

Original email follows with correct at the very bottom
==================================

Hi,

I am doing a simple test using Global Variables 2.2 which is failing.
Maybe someone knows the trick to this and could help.
I list what works then what fails below.
Then I show the simple bare bones code.

This works:
I can set the value inside the simple system with GV_SetInteger.
I can get the value back inside the simple system with GV_GetInteger
(see below)

This works:
I can set the value inside MS-Access with GV_SetInteger.
I can get the value back inside MS-Access with GV_GetInteger
(see below)

This fails:
I am trying to set an integer inside MS-Access-97
then bring that value into a simple test system.
It gives me the message
Trying access at data to future. Bars Reference value : -65516
The log file (see below) shows that the value coming in is -65516

Of note, the path to the DLL is correct since the internal tests work.
The paths are exactly the same in the system and in MS-Access.
Of note, I try "byRef" in MS-Access and it fails inside MS-Access.

Thanks,
John.

=======================================================
Part of the Simple system
=======================================================
variables:
SetGetValue(0);

if CurrentBar = 1 then
Begin
DefineDLLFunc: "C:\ProperPath\GlobalVariable.dll", int, "GV_GetInteger", int ;
DefineDLLFunc: " C:\ProperPath\GlobalVariable.dll ", int, "GV_SetInteger", int, int ;
{value1 = GV_SetInteger( 1, 5 ) ;} {Internal test commented out}
SetGetValue = GV_GetInteger( 1 ) ;
Print (File("C:\Access\ALog55.txt"), SetGetValue);
end;


=======================================================
MS-Access Code that failed due to interger definitions
=======================================================

Private Declare Function GV_GetInteger Lib "C:\ProperPath\GlobalVariable.dll" _
(ByVal intElementLoc As Integer) As Integer
Private Declare Function GV_SetInteger Lib "C:\ProperPath\GlobalVariable.dll" _
(ByVal intElementLoc As Integer, ByVal intSetValue As Integer) As Integer

Private intStatus As Integer


Private Sub fldBV_Upper_AfterUpdate()
Call funcGetIntegerWorks2
End Sub


Private Function funcGetIntegerWorks2()
Dim SetGetValue As Integer: SetGetValue = Me.fldBV_Upper
Dim intEleLoc As Long : intEleLoc = 1 'I tried integer here but it fails internally within MS-Access.
'I tried hard coding a 1 in the GV_SetInteger call but the result is the same

intStatus = GV_SetInteger(intEleLoc, SetGetValue)
If intStatus = -1 Then
MsgBox "GV_SetInteger failed with status = " & intStatus
End If
MsgBox "GV_GetInteger returned this value " & GV_GetInteger(intEleLoc)
End Function


=======================================================
MS-Access Code that worked when interger definitions
were changed to long definitions
=======================================================

Private Declare Function GV_GetInteger Lib "C:\Program Files\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal intElementLoc As Long) As Long
Private Declare Function GV_SetInteger Lib "C:\Program Files\TS Support\MultiCharts\GlobalVariable.dll" _
(ByVal intElementLoc As Long, ByVal intSetValue As Long) As Long

Private Sub fldBV_Upper_AfterUpdate()
'Call funcGetIntegerWorks2 'the original call above was commented out
Call funcGetIntegerWorks3
End Sub

Private Function funcGetIntegerWorks3()
Dim SetGetValue As Long: SetGetValue = Me.fldBV_Upper
Dim intEleLoc As Long: intEleLoc = 1
intStatus = GV_SetInteger(intEleLoc, SetGetValue)
If intStatus = -1 Then
MsgBox "GV_SetInteger failed with status = " & intStatus
End If
MsgBox "GV_GetInteger returned this value " & GV_GetInteger(intEleLoc)
End Function

arjfca
Posts: 1260
Joined: 23 Nov 2010
Has thanked: 716 times
Been thanked: 221 times

Re: MS-Access-97 sending global variables to MultiCharts wor

Postby arjfca » 08 Jul 2011

Hello John

This is an old post. I'm trying your code in Excel VBA. I got an error on : Me.Fldvb_AfterUpdate.

Any idea how I could test it.

Code: Select all

Private Function funcGetIntegerWorks3()
Dim SetGetValue As Long: SetGetValue = Me.fldBV_Upper
Dim intEleLoc As Long: intEleLoc = 1
intStatus = GV_SetInteger(intEleLoc, SetGetValue)
If intStatus = -1 Then
MsgBox "GV_SetInteger failed with status = " & intStatus
End If
MsgBox "GV_GetInteger returned this value " & GV_GetInteger(intEleLoc)
End Function


Have a great weekend
Martin


Return to “User Contributed Studies and Indicator Library”