A
Andy
I have opened an Excel spreadsheet from Access code and passed the value of a
particular cell (in text format) to an Access varaible (pubg1) in Variant
format - fine.
When I try to covert the Access variable to an Integer variable (intvar)
using the Val function the code fails with an overflow error.
Can any one make sense of this? Subset of the code :-
Dim pubg1 as Variant
Dim intvar as Integer
Set objWkb = objXL.Workbooks.Open("c:\PM.xls")
Set objSht1 = objWkb.Worksheets("PM")
i = 3
With objXL
.Visible = False
With objSht1
pubg1 = .Range(.Cells(i, 1), .Cells(i, 1)).Value ' range
format is text
End With
.Quit
End With
objXL.Quit
Set objSht1 = Nothing
Set objWkb = Nothing
Set objXL = Nothing
intvar = Val(pubg1) ' fails here with overflow error and err value 6.
Thanks.
particular cell (in text format) to an Access varaible (pubg1) in Variant
format - fine.
When I try to covert the Access variable to an Integer variable (intvar)
using the Val function the code fails with an overflow error.
Can any one make sense of this? Subset of the code :-
Dim pubg1 as Variant
Dim intvar as Integer
Set objWkb = objXL.Workbooks.Open("c:\PM.xls")
Set objSht1 = objWkb.Worksheets("PM")
i = 3
With objXL
.Visible = False
With objSht1
pubg1 = .Range(.Cells(i, 1), .Cells(i, 1)).Value ' range
format is text
End With
.Quit
End With
objXL.Quit
Set objSht1 = Nothing
Set objWkb = Nothing
Set objXL = Nothing
intvar = Val(pubg1) ' fails here with overflow error and err value 6.
Thanks.