开发者

How do I assign a function that returns a value to a variable?

So I have a class called Transactions and I put all my functions there. The problem is, when I try to call that specific function and assign it to a开发者_C百科 variable, there is a "ByRef Argument Type mismatch" error that keeps on bugging me. Help please :)

Public Function GetUserID(name As String) As Integer
    Dim gotID As Integer
    Dim rec As Recordset
    Call connectDB
    sSQL = "select ID from User where Name ='" & name & "'"
    Set rec = CurrentDb.OpenRecordset(sSQL)
    gotID = rec(0)
    GetUserID = gotID
End Function

Private Sub btnAcctAdd_Click()
    Dim tr As Transactions
    Set tr = New Transactions

    Dim ID as Integer
    Dim name, username, password As String

    name = cmbName.Value
    'MsgBox name
    ID = tr.GetUserID(name)
    'MsgBox ID
End Sub


The way it is, only password is being declared as string, the other 2 are object.

So change the code to this and the error will go away:

Dim name As String, username As String, password As String
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜