byRef arrgument mismatch

G

Guest

Hi - Im getting a byref argument mismatch on my watchlist element of array
myWatchlist, which I think means variable type mismatch. How do i fix this
please?

Bruce


Function updateYahooRTQ()
DoCmd.SetWarnings False
myWatchlist = Array("q_Watchlist_ASX200", "q_Watchlist_ASX201-400")

For Each watchlist In myWatchlist
Call YahooQuotes(rtQuote(watchlist))
DoCmd.TransferText acImportDelim, "SpecYahoo", "tbl_Intraday",
"D:\AAA\ASX\Yahoo\Download\YahooDownload.csv", False, ""
Next watchlist

DoCmd.SetWarnings True
End Function
 
D

Douglas J. Steele

How is rtQuote defined? I'm assuming you've declared the parameter As
String, and watchlist (which is what you're passing to it) is a Variant.

Either change YahooQuotes to accept a variant, or call it using

Call YahooQuotes(rtQuote(CStr(watchlist)))

Incidentally, the fact that your code works at all implies that you haven't
told VBA to force declaration of all variables. That's not a good idea: it
can lead to hours of frustrating debugging when you accidentally miskey a
variable name in one place. I'd strongly recommend going into the VB Editor,
selecting Tools | Options from the menu and check the Require Variable
Declaration on the Module tab. Yes, it'll be a pain at first when you have
to go and declare all of your existing variables before the code will work,
but believe me when I say it'll save you lots of time in the long run. (I've
never figured out why that's not the default setting!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top