Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help - ByRef argument Type Mismatch.

Status
Not open for further replies.

Robeen

Programmer
Mar 25, 2003
38
0
0
US
Here's [in my opinion] the pertinent code:

1. Clicked event that Calls the Function which is in a bas module.
Private Sub cmdDefaulters_Click()

Dim strSQLText, strMsgText, strFolio, StrCode As String
Dim curAmount, curAmountOwed As Currency

strCnn = ConnectString 'ConnectString is a function in a Bas Module that returns the connection string.

'rstFolio & rstCode are Declared in Bas Module As Recordset.
Set rstFolio = New ADODB.Recordset
Set rstCode = New ADODB.Recordset

strSQLText = "Select [Folio] from [StudentDataTest]"

Set rstFolio.DataSource = ExecuteSQL(strSQLText, strMsgText)

StrFolio = RstFolio!Folio

End Sub

'2. This is the Function Declaration: in a Bas Module.
Public Function ExecuteSQL(ByVal SQL _
As String, MsgString As String) _
As ADODB.Recordset

*******

When I try & run with a full compile I get:
"ByRef argument Type Mismatch"
& it highlights "strMsgText"
in "ExecuteSQL(strSQLText, strMsgText)"

It appears to be running fine but it wont compile. . .

Any ideas?

Robeen
 
I could be wrong, but I remember having a discussion with a professor a LONG time ago about declaring variables.

Dim strSQLText, strMsgText, strFolio, StrCode As String
Dim curAmount, curAmountOwed As Currency

The above statement declares, trSQLText,strMsgText,strFolio, and curAmount as Variant and Strcode as string and curAmountOwed as currency

You should declare everything as:

Dim strSQLText as String
Dim strMsgText as String
Dim strFolio as String
Dim StrCode as String
Dim curAmount as Currency
Dim curAmountOwed as Currency



Rob
 
yup your right rdavis, only the last variable on each line is declared as a type. (just to confirm your "I could be wrong moment")

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
Thanks guys!
I come from a PowerBuilder background where you can declare
like that . . . how silly of me to expect it to be similar in VB . . .

If something's that easy - would it be a Microsoft product??
:) [oooooof!!! where did that come from???]

I've made the changes & everything's fine now!!
Much appreciated!!

Robeen
 
Microsoft fixed that in .NET, where you *can* have a list of variables who will all be of the correct type.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top