I have a test project I'm using to familiarise myself with VB6. Just a listbox, a button to get info, and a button to clear info:
“Method or Data Member Not Found” When Trying to Execute Database Code. Compile Error: Method or Data Member Not Found. At first I thought it might be something to do with the event/button, that some sort of binding between them wasn't present. Can a Visual Basic 6 Class Property Type be an Enum. Path Not Found VB6-2. EDIT OP reports problem not resolved. Try these steps to narrow down the issue.Do this on the machine that you are having problems with 1. Open a new Visual Basic 6 Project - Standard EXE 2. Add the DBGrid component to the Project, Components 3. Take note of the location and name of the OCX (I may have got the name wrong above!) 4.
Code:
The following error appears when I click the Get Items button (btnGet):
Compile Error: Method or Data Member Not Found
At first I thought it might be something to do with the event/button, that some sort of binding between them wasn't present. But just putting in something like 'MsgBox('Hello')' works fine. Yet it doesn't even seems to get to the line where the GetMenuItems function is called before throwing the error.This being my first whirl with VB, I'm a little stumped.
EDIT - I've had a look at the UDL file I was using too. Tested that and its connecting ok on its own.
dbr
dbrdbr12722 gold badges55 silver badges1818 bronze badges
2 Answers
In
Sub btnGet_Click
, useAssigning object references without using
Set
is hardly ever the right thing to do. For what it's worth, omitting Set
references the left-hand side's default property; this was part of VB6 (OK, VB4, when classes were introduced) as a help to VB3 programmers, before there were such things as objects. Whatever kind of object lstResults.DataSource
returns likely does not have a default property, leading to the 'Method or data member not found' error.prprcupofcoffeeprprcupofcoffee
- You've got a private sub btnGet_Click() calling a public function GetMenuItems(), which may cause problems.
- Also I'm not sure you can use a udl as the connection string. Instead, open the UDL (you may need to change the file extension to .txt temporarily), take the connection string out, and use that in place of the file name.
- Also, check the stored procedure exists dbo.GetMenuItems
12k44 gold badges8080 silver badges9999 bronze badges
Not the answer you're looking for? Browse other questions tagged vb6ado or ask your own question.
For those gurus out their, could you all please give me a hand on the following code of my VB 6 codeas it resulting 'Compiler Error : Method or Data Member not found' error output..?
My codes,
Private Sub cmdOK_Click()
Dim PangkalanData As Database
Dim DaftarKod As Recordset
Dim SQL
SQL = 'SELECT NAMA,KOD,KELOMPOK FROM DAFTARKOD '
SQL = SQL + ' WHERE NAMA = ' + frmLAPORANBAKISTOKSEMASA.cboNamaStok.Text + ' ' '
'pastikan semua Then
MsgBox 'Sila Lengkapkan Semua Data Yang diminta...', 13, 'Belum Lengkap...'
Else
Set PangkalanData = Workspaces(0).OpenDatabase('F:Projek Vb5stok2.mdb')
Set DaftarKod = PangkalanData.OpenRecordset(SQL, dbOpenDynaset)
If DaftarKod.RecordCount = 0 Then
MsgBox 'Nama Stok Tiada Dalam Rekod...', 13, 'Tidak Dijumpai...'
Exit Sub
Else
frmLAPORANBAKISTOKSEMASA.txtKod.Text = DaftarKod![KOD]
frmLAPORANBAKISTOKSEMASA.txtKelompok.Text = DaftarKod![KELOMPOK]
End If
Report1.Destination = 0
FmlText$ = '{BAKISTOKSEMASA.KOD}=' + Trim(frmLAPORANBAKISTOKSEMASA.txtKod.Text) + 'AND {BAKISTOKSEMASA.KELOMPOK}=' + Trim(frmLAPORANBAKISTOKSEMASA.txtKelompok.Text) + ''
Report1.SelectionFormula = FmlText$
Report1.ReportFileName = LocText$ + 'c:LaporanBakiStokSemasa.rpt'
Report1.Action = 1
DaftarKod.Close
PangkalanData.Close
End If
End Sub
--> from the debug section of this code, it seems that destination cause the error to be the triggerred out..
any ideas how i going to screw up my code as abovemeent mentioned...
thanks in advance