Raybert
07-14-2011, 10:30 AM
Hello everyone!
I'm hoping someone can help me solve this problem.
I have a VBA code which is set to retrieve values from a table in Access. When it retrieves this data, if it is a small number (0.00713 for instance) the recordset returns a value of 0. When i change the value to 10, it works properly. It seems to only be reading integers.
The table is formatted as Number / General Number and the variable I am saving the value into is Long.
I've copied a section of my code. If anyone could shed some light on this it would be greatly appreciated!
Ray
CODE:
Dim rst As New ADODB.Recordset
Dim PINC as Long
Do
If yearcount < 2015 Then
rst.Open "SELECT * FROM [2015] WHERE [ID] = 'Gasoline';", ConnectDB, adOpenStatic
ElseIf 2015 < yearcount < 2025 Then
rst.Open "SELECT * FROM [2025] WHERE [ID] = 'Gasoline';", ConnectDB, adOpenStatic
ElseIf 2025 < yearcount Then
rst.Open "SELECT * FROM [2035] WHERE [ID] = 'Gasoline';", ConnectDB, adOpenStatic
End If
PINC = rst(projectiontype)
MsgBox (PINC)
yearcount = yearcount + 1
'Close rst
rst.Close: Set rst = Nothing
Loop Until yearcount > (LCStart - 1)
I'm hoping someone can help me solve this problem.
I have a VBA code which is set to retrieve values from a table in Access. When it retrieves this data, if it is a small number (0.00713 for instance) the recordset returns a value of 0. When i change the value to 10, it works properly. It seems to only be reading integers.
The table is formatted as Number / General Number and the variable I am saving the value into is Long.
I've copied a section of my code. If anyone could shed some light on this it would be greatly appreciated!
Ray
CODE:
Dim rst As New ADODB.Recordset
Dim PINC as Long
Do
If yearcount < 2015 Then
rst.Open "SELECT * FROM [2015] WHERE [ID] = 'Gasoline';", ConnectDB, adOpenStatic
ElseIf 2015 < yearcount < 2025 Then
rst.Open "SELECT * FROM [2025] WHERE [ID] = 'Gasoline';", ConnectDB, adOpenStatic
ElseIf 2025 < yearcount Then
rst.Open "SELECT * FROM [2035] WHERE [ID] = 'Gasoline';", ConnectDB, adOpenStatic
End If
PINC = rst(projectiontype)
MsgBox (PINC)
yearcount = yearcount + 1
'Close rst
rst.Close: Set rst = Nothing
Loop Until yearcount > (LCStart - 1)