visual basic run time error 5 class
Dear Friend,
I'm getting problem in vb class module.I have no idea about class module but i was created class file. When i run my application it showing run time error '5'.
Any one can help me for this problem.
In form code:
Code:
Dim List As SpdListing
If KeyCode = vbKeyF2 Then
DoEvents
Set List = New SpdListing --> Here i am getting error
List.Class_Initialize
With List
.SpdShowList Me, SpdStyle, SpdStyle.ARow, SpdStyle.ActiveCol, "StyleId", "Style", "Style", Qry = ""
End With
End If
Class Module Code:
Public Type SpdList
Frm As Object
spd As Object
ARow As Integer
ACol As Integer
Field1 As String
Field2 As String
TblObj As String
Qry As String
End Type
Public Function SpdShowList(CurrentFrm As Object, Currentspd As Object, ARow As Integer, ACol As Integer, Field1 As String, Field2 As String, TblObj As String, Qry As String) As String
Dim List As SpdList
With List
.Frm = CurrentFrm
.spd = Currentspd
.ARow = ARow
.ACol = ACol
.Field1 = Field1
.Field2 = Field2
.TblObj = TblObj
.Qry = Qry
Strsql = "Select " & .Field1 & VBA.chr(13) & "," & VBA.chr(13) & .Field2 & VBA.chr(13) & " From " + .TblObj
If .Qry <> "" Then
Strsql = Strsql & VBA.chr(13) & " Where " & VBA.chr(13) & .Field1 & VBA.chr(13) & " In(" & .Qry & ")"
Else
Strsql = Strsql & VBA.chr(13) & " Where " & .Field1 & "='" & FrmSpdListing.SpdFilter.Text & "%'"
End If
End With
Set SpdRs = New ADODB.Recordset
SpdRs.Open Strsql, SpdCn, adOpenStatic, adLockReadOnly
Set FrmSpdListing.SpdGrid.DataSource = SpdRs
'FrmSpdListing.SpdGrid.Columns(0).Width = 0
FrmSpdListing.Show
End Function
Re: visual basic run time error 5 class
Welcome to VBForums :wave:
Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'VB6 and earlier' forum
Re: visual basic run time error 5 class
Hi si_the_geek,
Thanks to inform me. Since i am new person in this fourm. SO can u tell me how to post my question.
Thanks
Re: visual basic run time error 5 class
Quote:
Set List = New SpdListing --> Here i am getting error
List.Class_Initialize
You don't show the Class_Initialize code, which may be causing the error.
BTW, the Set statement above causes the Class_Initialize code to be
executed.
Also, even if the Class_Initialize code didn't cause an error,
the line List.Class_Initialize would cause another error, since Class_Initialize
is private to the class.
Re: visual basic run time error 5 class
Quote:
Originally Posted by
VBClassicRocks
You don't show the Class_Initialize code, which may be causing the error.
BTW, the Set statement above causes the Class_Initialize code to be
executed.
Also, even if the Class_Initialize code didn't cause an error,
the line List.Class_Initialize would cause another error, since Class_Initialize
is private to the class.
Thanks it is working.