Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

OpenRecordset Method

Can anyone help me with this code, tell me where im goign wrong.

Dim rec As Recordset, query As String, db As Object

query = "SELECT EmployeeID , FirstName , LastName " _
& "FROM Employee " _
& "WHERE DepartmentName = '" & deptComboBox.Text & "';"

Set db = Application.CurrentDb
Set rec = db.OpenRecordset(query, 1)

This gives the error :

"Run-time error '3011':

The Microsoft Jet engine could not find the object 'SELECT EmployeeID, FirstName, LastName FROM Employee WHERE DepartmentName = 'Finance';'. Make sure the object exists and that you spell its name and path name correctly"

This is for a form in Access. I have run the query in Access and it gives the correct results so the query is correct.

I am in desperate need of help.

Thanks in advance

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Sorry I fail to see the fault here. From what i remember that would work in Access 97, but it doesn't on 2000 which I'm using now:
- "OrdemClass" is a query
- "Ordem" is a table
- Tried definig gdb as database/won't work Object doesn't make any diference...

' Dim gdb As Object
Dim rsOrd As Recordset
Dim rsTmp As Recordset

Set gdb = CurrentDb
Set rsTmp = gdb.OpenRecordset("OrdemClass", dbOpenDynaset)
' -> the above line return an "Invalid Argument" (dbOpenDynaset?)
Set rsOrd = gdb.OpenRecordset("Ordem")
' -> this one returns "Type Mismatch" error

I don't see how could make it work. Thanks in advance...

I am starting a new VB Application using DAO 3.51 Object Library.

For some reason, my OpenRecordset gives me an error: "Method or Data Member not found".

Does anyone know why this is happening? What am I missing here??

Thanks in advance!

This is my first posting as a beginner n i would really appreciate any help possible:

The following code results in a "too few parameters. expected 1". it bottoms out on the set recordset line. I believe this is because the recordset i am trying to open is dependant on a control in the form which is open at run time.

i really need help and any would be really appreciated

set Recordset = CurrentDb.OpenRecordset("qryfindherocard")

If Recordset.RecordCount < 1 then

DoCmd.OpenQuery "APqryAddNewHeroFromNorpass"

DoCmd.OpenQuery "UDqryAddNewHeroFromNorpass"

End If

me.RecordSource = "qryFreeNorpassRecords"

Too Few Parameter In OpenRecordset ?
Hi, all. I am a newbie here.

I have an extremely simple question which have been annoying me for
three days!

In one subroutine, I have

Dim db As Database
Dim rs As Recordset
Dim mysql As String


Set db = CurrentDb
Set rs = db.OpenRecordset(mysql)


Whenever I run the program and the event is activated,
the program stop at the last sentence, informing that thereis a
run-time error '3061', and that "Too few parameters. Expected 1".

I have tried several other ways such as
Set rs = db.OpenRecordset(mysql, dbOpenDynaset, dbReadOnly)

I really don't know what is wrong.

But if I use any sample database from Access and create a new
form and add such codes, it woks!

Any idea or comment is appreciated here.

Openrecordset Question
I want the user to open a table from a combo box.
I want this opening order by a field.
So i use

Set rstacciones = dbsDataBase.OpenRecordset("select* from &Combo1.Text& order by tipo, dbOpenDynaset")

But always get an error because doesn´t recognize the table.

What´s wrong ?There is other ways to do that?

OpenRecordset Error

I have the following code in a form's load event:

dim db as Database
dim rs as Recordset

set db = OpenDatabase("dummy.mdb")
set rs = db.OpenRecordset("Select * from table1")

Somehow, I'm getting a "Type mismatch" error on the set rs ..." line ! According to the VB on-line help and examples, I SHOULD NOT be gettign any errors ! The debug says that "rs = nothing".

Any ideas anyone ???

Db.OpenRecordset ADO Counterpart
Hello i would like to doubleclick any record in my listview and the record will display in texboxes.

I have this code using DAO. What is its counterpart in ADODB?

VB Code:
Private Sub lstProducts_DblClick()  If rsProducts.State = adStateOpen Then rsProducts.Close  rsProducts.Open sSQL, oConn, adOpenStatic, adLockOptimistic   If lstProducts.ListItems.Count <> 0 ThenSet rsProducts = db.OpenRecordset("SELECT * FROM Products WHERE ProdCode = '" & lstProducts.ListItems.Item(lstProducts.SelectedItem.Index).Text & "'")  'Call RetFields  Frame1.Enabled = True  txtDescription.SetFocus  SendKeys "{home}+{end}"  cmdAdd.Enabled = FalseEnd IfEnd Sub

DAO: OpenRecordSet(tablename Or SQL ???)
My code is below:

VB Code:
Set db = OpenDatabase(DATABASE_FILE_MAU)        sql = "SELECT * FROM tonghop ORDER BY stt"        Set rs = db.OpenRecordset(sql)                    rs.MoveFirst                    rowcount = rs.RecordCount

The rowcount was 1 after these codes run while the true answer was 10.
but when i change the sql variable to "tonghop" which is the table name, i got the right answer. but the recordset was not ordered by stt. I just want the right rowcount and the right order of the recordset but both ways seem not right.

Have anyone got stuck with this before ? How did you solve this problem ?

DAO Openrecordset With More Than One Path
Is it possible to use dao and openrecordset to query dbf files in more than one path? Example of query:

VB Code:
sMainPath="d:"sQuery="select * from 'd:firstpath able1" t1, 'd:secondpath able2" t2"Set dbDatabase = OpenDatabase(sMainPath, False, False, "dBase IV;")Set rsRecordSet = dbDatabase.OpenRecordset(sQuery, dbOpenSnapshot, dbReadOnly)

It doesn't appear to be working. I'm getting a message about error 3450 - incomplete query clause.

What Is Wrong In The Openrecordset? Thanks Dee-u
Hi guys,
I used the following code, it gives "Type Mismatch" Error on openrecordset statement. Any one can help me.

VB Code:
Dim db1 As DatabaseDim rs1 As Recordset        Set db1 = OpenDatabase(App.Path + "hospital.mdb")Set rs1 = db1.OpenRecordset("select * from Invoice", dbOpenDynaset, dbDenyRead + dbDenyWrite)

OpenRecordSet Question
Say in my Access database I have 5 tables.
Now would I have to use a separete instance for each table

Set rstInfo = .OpenRecordset("Info")
Set rstCustomer = .OpenRecordset("Customer")
Set rstEmployee = .OpenRecordset("Employee")

Or could I put them all into once instance

Set rstInfo = .OpenRecordset("Customer" & "Employee" & "Info")

Or something like that, as I'm not sure how the 2nd way would work if it's possible.

OpenRecordset Problem
I have a small problem. I'm trying to make a small prototype of a system I made in Ms access for a presentation.
Well basically I have this problem with record set in a small function

Private Sub Varenrliste_Change()

Dim Resultat As Recordset
Dim Dbs As Database

Set Dbs = OpenDatabase("c:My documentspresentation.mdb")
Set Resultat = Dbs.OpenRecordset("SELECT * FROM Vare WHERE Vare.Varenr=Varenrliste.Text;")

Varenavntext.Text = Resultat.Fields("Varenavn")
Varebeskrivelsetext.Text = Resultat.Fields("Varebeskrivelse")
Varepristext.Text = Resultat.Fields("Varepris")


End Sub

Varenr is an integer and so is Varenrtext.text
however everytime I try to compile it says:

Run-time error 3061:
Too few parameters. Expected n.

can anybody please help me

QueryDef Or Db.openrecordset
Can anyone tell me which one is best to use? I just want to retrieve data from an msaccess db.
Is it best to use either a permanent/temp querydef or doesn't it really matter?


Openrecordset Problem
I am writing the code to put in a subform to a form in MS Access2000. The sub form is related to main form so I created a query and connected as I had done before but I get an error with the openrecordset. the code is below can anyone see where I am going wrong.....P.S. the query does work alone.

Option Compare Database

Option Explicit
    Private m_Entitlement_Well As DAO.Recordset
    Private m_InfoChanged As Boolean
    Private m_NewRecord As Boolean
Private Sub Form_Open(Cancel As Integer)
Dim sSQL As String

    sSQL = "SELECT [Entitlements Well Level].* " & _
            "FROM [Entitlements Well Level] " & _
            "WHERE ((([Entitlements Well Level].WELL_LVL_ID)=[Forms]![Entitlements Header]![txtHeaderId]))"

Set m_Entitlement_Well = CurrentDb.OpenRecordset(sSQL, dbOpenDynaset, dbconsistent, dbpessimistic)
End sub

Openrecordset,sql Expression
Why am I getting a run time error 3464?
Data Type mismatch in criteria expression

I am running a test query on an access database with the following code:
Static pubidno As Integer
Static stateno As String

pubidno = 100
stateno = "NY"

Dim dbs As Database, rst As Recordset
Set dbs = OpenDatabase("c:program filesdevstudiovbdb1.mdb")
Set rst = dbs.OpenRecordset("SELECT * FROM Publishers " _
& "WHERE PubID &lt; '" & pubidno & "' " _
& "AND State = '" & stateno & "' " _
& "ORDER BY Name ")
Set rst = Data1.Recordset

Use Exiting Query As OpenRecordset
I am currently using a query within a form for use in an Excel Spreadsheet automation Module. I would like to just use the query as my Open Recordset from which to call my fields. Here is an example of what I am doing:

mySQL = "SELECT [ReferralID]" _
& " FROM [tbl_ReferralMain]" _
& " WHERE ((([tbl_ReferralMain]![ReferralID])= [Forms]![tbl_ReferralMain]![ReferralID]));"

Set db = DBEngine(0)(0)

Set qdf = db.CreateQueryDef("qryReferralDistribution_Single1", mySQL)

DoCmd.OpenForm "frm_ReferralDistribution", acViewNormal

- This form has a query called qryReferralDistribution_Single2 loaded which feeds from the QueryDef above.

-From here I am doing:
With xlsheet
.Range("i1 : k1").MergeCells = True
.Range("i1 : k1").Font.BOLD = True
.Range("i1 : k1").Borders.LineStyle = xlContinuous
.Range("i1 : k1").Borders.Weight = xlThick
.Range("i1 : k1").NUMBERFORMAT = "mmmm dd,yyyy"
.Range("i1 : k1").Font.Size = 8
.Range("i1 : k1").Value = now()

I would like to just use my established 2nd query rather than the Form to eliminate steps in my code.

SQL Statement In Querydef Vs. Openrecordset
i've got a problem where i think the solution might be quite simple but i just can't work it out !

e.g. SQL - Statement in VBA Access for just copying a table

(variable "answer" is a string)

SQL_QUERY = "SELECT Test_Data_A1_Template.* INTO Test_Data_A1_Template_" & answer & " FROM Test_Data_A1_Template"

Set qd = db_A1.CreateQueryDef("Abfrage Copy", SQL_QUERY)

Set rs_dy_test_data = db_A1.OpenRecordset("Test_Data_A1_Template_" & answer, dbOpenDynaset)

Set rs_dy_test_data = rs_dy_test_data.OpenRecordset()

like this it always works but i don't want to have the query so i tried :

SQL_QUERY = "SELECT Test_Data_A1_Template.* INTO Test_Data_A1_Template_" & answer & " FROM Test_Data_A1_Template"

Set rs_dy_test_data = db_A1.OpenRecordset(SQL_QUERY, dbOpenDynaset)

which should work, but it doesn't

error message is runtime error '3219' and 'operation not allowed' (in German it is: unzulässige Operation)

i hope somebody can help me

Run-Time Error '91' While Using Db.OpenRecordset
Hi all...

I'm trying to write information into a table using the rs.AddNew feature. But when I'm trying to open the recordset it gives me the following error:

Run-time Error '91' Object Variable or With block variable not set
I am wondering what could be the issue here, cause i'm using a code similar to this one in another command button, and it works there.

Here's the code i'm trying to use:

Private Sub cmdPayout_Click()
Dim db As Database
Dim rs As Recordset
Dim bedrag As Integer

Set rs = db.OpenRecordset("tblStatus")

If WedstrijdScorePloeg1 = PronostiekScorePloeg1 And WedstrijdScorePloeg2 = PronostiekScorePloeg2 Then
bedrag = PronostiekBedragInzet * 3
' Gewonnen
rs!StatusLogin = PronostiekGokkerLogin
rs!StatusGewonnen = bedrag
rs!StatusVerloren = ""

ElseIf WedstrijdScorePloeg1 = PronostiekScorePloeg1 And WedstrijdScorePloeg2 <> PronostiekScorePloeg2 Then
bedrag = (PronostiekBedragInzet / 2) * 3
' Gewonnen 1 ploeg
rs!StatusLogin = PronostiekGokkerLogin
rs!StatusGewonnen = bedrag
rs!StatusVerloren = ""

ElseIf WedstrijdScorePloeg1 <> PronostiekScorePloeg1 And WedstrijdScorePloeg2 = PronostiekScorePloeg2 Then
bedrag = (PronostiekBedragInzet / 2) * 3
' Gewonnen 2 ploeg
rs!StatusLogin = PronostiekGokkerLogin
rs!StatusGewonnen = bedrag
rs!StatusVerloren = ""

ElseIf WedstrijdScorePloeg1 <> PronostiekScorePloeg1 And WedstrijdScorePloeg2 <> PronostiekScorePloeg2 Then
bedrag = PronostiekBedragInzet
' Verloren
rs!StatusLogin = PronostiekGokkerLogin
rs!StatusGewonnen = ""
rs!StatusVerloren = bedrag

End If
MsgBox "Payouts Added"
End Sub

Foxdb.Openrecordset Error

I'm trying to open a Foxpro table but I keep getting a run-time error 3011.

The code I'm using is below:

Set Foxdb = OpenDatabase("E: empauto", False, False, "Foxpro 2.5;")

Set rstExtSource = Foxdb.OpenRecordset("ext_source")

When it gets to the second line I get the error saying it cant find the object "ext_source" or that it is spelt wrong.

The spelling is correct and the table exists.

Anyone any ideas?

Invalid Operation In OpenRecordset
I am sorry to post a reply on the back of this issue, but it seems to relate to a problem I am looking to resolve. Can I use an existing select query as a recordset? I am currently Inserting data into a hold table then using a Form to export data:

DoCmd.OpenForm "frm_ReferralDistribution", acViewNormal
Set xlobject = CreateObject("excel.sheet.5")
Set xlsheet = xlobject.Application.activeworkbook.sheets("Sheet1")
Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("tbl_ReferralDistribution")

On Error GoTo errorhandler

DoCmd.GoToRecord acDataForm, "frm_ReferralDistribution", acFirst

Do Until rst.EOF
Debug.Print rst!ReferralID

From here I am automating the fileds from the form into a formatted spreadsheet (With xlobject ... End With).

Thanks everyone.

Invalid Operation In OpenRecordset
Hi, I have an Access module with a function that is giving me an Invalid operation error in the OpenRecordset statement (in bold below).

Function AppendData()

Dim MyWkDay As Integer
Dim i As Integer
Dim DtInptBx As String
Dim SlsInptBx As String
Dim DBase As Database

MyWkDay = Weekday(Date)

If MyWkDay = vbTuesday Then
i = 3
ElseIf MyWkDay = vbWednesday Then
i = 4
ElseIf MyWkDay = vbThursday Then
i = 5
ElseIf MyWkDay = vbFriday Then
i = 6
End If

DtInptBx = InputBox("Enter a date" & Chr(13) & "Use format yyyymmdd", "BJ's Hotkey", _
Format(Date - i, "yyyymmdd"))
SlsInptBx = InputBox("Enter Sales Amount")

query = "INSERT INTO tblStoreHistory ( Chain, Store, Qty, [Whsl Amt], ADJDT )" & _
"SELECT 3022 AS Chain, qryClean.Store, Sum(CDbl([Qty_symbol] & [Qty_right1] & [Qty_right2] & [Qty_cnvt])) AS Qty," & _
"Sum(qryClean.WhsPrc) AS SumOfWhsPrc, DtInptBx AS ADJDT FROM tblQty INNER JOIN qryClean ON tblQty.Qty_alpha = qryClean.Qty_right3 " & _
"GROUP BY 3022, qryClean.Store, DtInptBx ORDER BY Sum(CDbl([Qty_symbol] & [Qty_right1] & [Qty_right2] & [Qty_cnvt])) DESC"

Set DBase = CurrentDb
Set RecSet = DBase.OpenRecordset(query, dbOpenDynaset)


Set RecSet = Nothing
Set DBase = Nothing

End Function
Could it be the way I'm opening the Recordset - dbOpenDynaset?

Thanks in advance for any help!

OpenRecordset Type Mismatch
I'm trying to open a table in the current Access database that is stored locally. When i run the below code I get a Type mismatch error on the last line (Set RecSet =....)

Function OpenSales()

Dim RecSet As Recordset, query As String, DBase As Database

query = "SELECT [Sale Date] " _
& "FROM tblDailySales " _
& "WHERE [Sale Date] Is Not Null;"

Set DBase = CurrentDb
Set RecSet = DBase.OpenRecordset(query, dbOpenSnapshot)

End Function
Is there something I'm doing wrong. I'm running Access 2000 and DAO 3.6. Thanks in advance for any help!

Openrecordset() Returns Empty
I am wondering whether anybody has encountered the same problem. The statement

A_querydef.SQL= "certain valid sql statement"

won't return any record. And if you go to Access and open the new created A_querydef, it is empty too. But if you cancel or add any unrevelant field by tick the box in the design view , then the recordset won't not empty, and it contains exactly what "certain valid sql statement" should return.

Any ideas? How can I force the recordset be what the "certain valid sql statement" shoud return?

Best regards,
Michael Chen

OpenRecordSet Multiple Times
VB Code:
For i = 0 to 40Set rst = rst.openrecordsetnext

Why does it return a error and how can i stop the error.

How Do You Solve This Problem Regards To Openrecordset

I have the following code... but recently when I was running it, it gives me bug... it says type mismatch at the highlighted line.
In the past it was working fine, until today it failed me... Could anyone give me some pointers... Thanks in advance..

Private Sub Command0_Click()
Dim db As Database
Dim objrec As Recordset
Dim str As String
Set db = DBEngine.Workspaces(0).Databases(0)
str = "select * from fdata"
Set objrec = db.OpenRecordset(str)
While Not objrec.EOF
    MsgBox objrec.Fields("sedol")
End Sub


Type Mismatch In OpenRecordset
I'm using the following code to open an access db.

    Dim SQL As String
    SQL = "SELECT Projects.ProjectName, Projects.ProjectDesc, Projects.ProjID" & _
          "Pages.PageName, Pages.PageURL " & _
          "FROM Projects LEFT JOIN Pages ON Projects.ProjID = Pages.ProjID;"
    Set gdbProjects = DBEngine.OpenDataBase(App.Path & "/ProjList.mdb")
    Set gRS = gdbProjects.OpenRecordset(SQL, dbOpenDynaset)
   If Not (gRS.BOF And gRS.EOF) Then
        OpenDataBase = True
        Set gRS = Nothing
        Set gdbProjects = Nothing
        OpenDataBase = False
    End If

I get a type mismatch eror on the orange line. I have checked the types for each of the fields I am requesting and I can't see anything that would generate the error.

I have DAO referenced. I'm confused because this is how I access DB's in all my VBA projects.

Thanks for looking.

The worst thing about wearing glasses is them being on your face.
Nothing is impossible, it just looks that way.

Error 3061 In OpenRecordset....HELP!!!!
This is the code:

 Dim db As dao.Database
 Dim rs As dao.Recordset
 Dim sql As String
 Set db = DBEngine.OpenDatabase("D:ProjectsReworkProjectRework.mdb")
 sql = "SELECT [Reason] FROM [JobSuf] WHERE [Job#] = '12345' AND [Suffix] = '111'"
 Set rs = db.OpenRecordset(sql)

I get error 3061 Too few parameters, at the last line when trying to open the recordset.
What is wrong?????

Type Mismatch On .openrecordset
This works in every Access application I have developed, except this one. Can anyone see what is wrong with this? When it gets to opening the DB I get a Type Mismatch error and can't see why. I checked references and made sure they were the same as other apps. So it really baffles me.

    Dim RS As Recordset
    Dim SQL As String
    Dim DB As Database
    Set DB = CurrentDb
    SQL = "Select * FROM Contests"
    Set RS = DB.OpenRecordset(SQL, dbOpenDynaset)

Here is the same code in another Access app.
    Dim RS As Recordset

     Set RS = DB.OpenRecordset("Select * From dataPointCalculations", dbOpenDynaset)
     RS.FindFirst "CalculationText='" & cboCalculation.Text

Thanks for looking,

The worst thing about wearing glasses is them being on your face.
Nothing is impossible, it just looks that way.

Simple OpenRecordset Problem
What is wrong with the following code? Am I missing a reference; am I missing a code line; am I missing my brain? All I'm trying to do is open a recordset to do some updates. I've done this a million times and for some reason it's not working today. What's up with that?? Here's the code:
Dim rsTbl As Recordset
Dim DBase As Database

Set DBase = DBEngine.OpenDatabase("H dtcunaffirmunaffirm.mdb", False, False)

If nAffirmType = 2 Then
Set rsTbl = DBase.OpenRecordset("Select * from tblEquity", dbOpenDynaset)
End If

What happens is it gives me a 'Type Mismatch' on the Set rsTbl line. I don't get it. Will someone help me please with this very simple problem? Thanks, Wendy


Type Mismatch With OpenRecordset
I'm getting a type mismatch error when I try to open a recordset using a string and dbOpenSnapshot.

Set rstTemp = dbs.OpenRecordset(strSQL, dbOpenSnapshot)

If I copy the SQL from strSQL and make a new query, it runs. It doesn't matter what I set strSQL to, it won't run. I have another database that uses the same code, and it works in that database. Any ideas? Thanks.

Type Mismatch Error On OpenRecordSet
Im trying to export data records from an Excel spreadsheet to an Access table and im getting this error.

VB Code:
Dim db As DatabaseDim rs As RecordsetDim ws As Workspace     DBEngine.SystemDB = "C:Documents and SettingsSystem.mdw"    Set ws = CreateWorkspace("NewWS", "user1", "", dbUseJet)    Set db = ws.OpenDatabase("C:Documents and Settings estimport.mdb")    Set rs = db.OpenRecordset("EquipAll")

Set rs = db.OpenRecordset("EquipAll")

This returns me a Runtime error '13': Type Mismatch
even though the return type of the OpenRecordSet function is 'Recordset' and the rs object is of type 'Recordset'


CreateQueryDef, OpenRecordSet Only Returns 1 Record
I'm trying to populate a flexgrid in my VB 6.0 application with values from a query of an Access table:

    sql = sql & "SELECT * "
    sql = sql & "FROM SongInfo "
    sql = sql & "WHERE " & Sec1 & Sec2 & Sec3
    'Populate flexgrid
    Set db = OpenDatabase(Appl)
    Set qu = db.CreateQueryDef("", sql)
    Set rs1 = qu.OpenRecordset

Sec1, Sec2 and Sec3 are strings that the user creates by populating fields on the search form.  In this example, there's nothing in Sec2 or Sec3, so, sql ends up looking like this:

SELECT * FROM SongInfo WHERE SongTitle Like '*amazing*'

The problem is I'm only getting 1 record.  If I run the EXACT SAME QUERY in MS Access, I get multiple records, so it's working fine there.  I've tried all the different options (dbOpenDynaSet, dbOpenTable, etc.) without any success.  I know the flexgrid is working OK, because I've checked the recordcount before getting to the flexgrid code.  Any ideas?

VB 6.0
MS Access 2003

Open MDI Form From Method And Return To Method When MDI Is Unloaded(RESOLVED)
Please help. I have a function that runs everytime my program starts. When it gets to the function I would like to display an MDI form that goes through several child forms. Once the mdi form is unloaded I would like to return to the startup function and continue through. Opening a Regular form as modal works fine but I have to use an MDI Form which you cannot do that way. Any suggestions??????????

Edited by - ziggy2416 on 3/24/2005 11:15:35 AM

Save Method Or Update Method? It's Driving Me Crazy
Hi Everyone,
    i'm writing an application using visual basic at the frontend and Sql Server 2000 at the backend.
i noticed that when my database table is empty only the save method(of visual basic) can store a record into it.But once it contains at least one record,the save method doesn't work again.So i have to update method.
At first it worked fine but now, it works on some forms in the application and not on others.Here's the code.Hope you can help I need to fix it as soon as possible

On Error Resume Next
 If AdoBuscode.Recordset.RecordCount = 0 Then
        MsgBox "Record has been saved"
        MsgBox "Record has been saved"
    End If

I used the record count property to indicate that the table is empty

Method Or Data Method Not Found??
this is probably a VERY simple question but I get the "Method or data method not found" error message when my prog comes to this part of code:

AttendanceForm.PresBox1 = Stu1(2)
AttendanceForm.ReasonBox1 = Stu1(3)
It can find the PresBox1 but not the ReasonBox1??

I've checked the name and cannot understand what the problem is . Will somone point out my stupidity before I go mad...

Xmlimport Method And XmlImportXml Method
What is the difference between these two methods. I am looking for a way to import XML data into a variant array. The code would look something like this. The method in line 2 is from my imagination, and is to give you an idea what I am looking for.

Dim varxmldata as variant
varxmldata = importxmldata.values

Why Does &"Method 'Open' Of Object 'Workbooks' Failed&" Become &"Method '~'...
I am trapping errors for notification purposes. When I run my program in the IDE the error is:"Method "Method 'Open' of object 'Workbooks' failed"But when I run the compiled executable it excludes information and instead becomes:"Method '~' of object '~' failed"I am not concerned with the reason for the error b/c I already know that. My concern is that the latter does not provide enough information to affectively diagnose the cause of the error.

Why does the error information get dropped in the executable? Is there any way to get it to look like the first message?

Why &"remove&" Method Can Not Remove Controls Added Using &"add&" Method?
I use "add" method to dynamically add some controls in the form, then I use "remove" method to remove them, but it doesn't work!
My code is like following.

Private WithEvents Command1 As CommandButton

Private Sub Command1_click()
' some codes to be executed when Command1 is clicked
End Sub

Private Sub AddControl()
Set Command1 = Controls.Add("VB.CommandButton", "Command1")
With Command1
.Visible = True
.Caption = "Command1"
.left = 2000
.top = 1000
.width = 500
.height = 200
End Sub

Private Sub RemoveControl()
Controls.Remove "Command1"
End Sub

When AddControl() is executed, a command button named "Command1" is added to the form. But when RemoveControl() is executed, there is error, and the
error message is "Run-time error '365': unable to unload
within this context". Why does this happen? Thanks.

Bit Blt Or Whatever Method...
My apologies to you all for a question that has been answered 100 times before, I tried to search for it, but couldn't find any results for some bizzare reason.

I have an array of 100 pictureboxes, 33x33 pixels that make up the map of my RPG. I want to have my character image be transparent, and not have the stupid backcolor in there. I've seen it done before, and I (kind of) did it myself a LONG time ago, but I have forgot.

just for referance, the pictureboxes are called "Map" and the map is 10x10, with the map indexes going 1-10 in the first line, 11-20 in the second, etc.
The NPCs/Characters are in a picturebox called NPC(Index) and all but the first one will be loaded at runtime.

Best Method
another opinion question.
i've read that you can supply the arguements to vb by the proper order (of course) or by naming the arguement and putting a := and the answer. and you can do those in any order.
is there a disadvantage to that? speed? reliablilty?
thank you

How Can I Run A VBA Method In VB6
Hello. I have a VB6 program that plugs data into an excel sheet that was written in VBA. Once the sheet is filled, I want to run two methods that are run by pushing buttons on the Excel sheet. By using the create a new macro method I've found out that the VBA code for these two methods is:

Application.Run "Autoport.XLS!UnhideCells"
Application.Run "Autoport.XLS!HideEmptyLevels"
Back in VB6, the variable I use to link to this excel sheet is Active_Excel. How do I run these two methods without copying and converting their code from VBA to VB6?

Use IF Method
use If method

'method 1 //work
If Not (rsDB!PHONE) = "" Then
RS3 = "NULL"
End If
'method 2 //not work
If Not (rsDB!PHONE) = "" Then RS3 = rsDB!PHONE Else RS3 = "NULL" End If

Hello, can you tell me why Method(2) Not work?
I hope use ONE line To Do All, because Method(1) very Not beautiful.

And if some vaule return NULL(no value/data), any method can replace them? only use (If)?

Mid Method
I am trying to use the 'Mid' method to get a ceratin text out of a textbox but this come up an error ('invalid procedure/call')

PicPath = Mid$(frmListImages.lstImages, 0, 11)

.Cls Method.
SOLVED: By double buffering manually.

Looking For A Method...
What is the method to return part of a string, depending on the starting and ending character (number)? Mid$ doesn't work in this situation because it needs a Length, not an end character. Thx.

Get Method
In this code:

Open FileName For Binary As #FileNumber
Get #FileNumber, , FileBinary
Close #FileNumber
What does the Get line mean? (code isnt meant to be functional)


What Do You Think Is The Best Method...
to calculate in VB6.0 the time worked from a database that have the arrive time in a record and the leave time in a different record.

I selected the info using a stored procedure.

Do you have any idea?

Which Method?
I'm writing up a program in VB to modify a table, and I need to create an update option. On the form, there's a listbox that will list the entries currently in the table (based on the "document name" field in the table) upon loading the form. When the user clicks on one of the listed names, information from the table (including the "document name", "file name", and "document description") will show up in textboxes on the form.

I've thought of two viable ways to do this, and was wondering if one way would be more efficient than the other (or perhaps there's a better way than the 2 I came up with).

1) Put all the data from the table into an n-dimensioned array when the form loads.
Pros: All the information is on hand and easily accessible when I need it.
Cons: Unnecessary usage of memory, especially if the table gets large and if most of the information won't be used.

2) Load up each list entry's information as the user moves through the list box.
Pros: Only retrieves the information as you need it.
Cons: Has to reconnect to the database & reload the data every time the user moves to another item in the listbox.

Comments appreciated ^_^

Best Method?
hi, I have a program i have made, that takes a screen shot of four places on the screen, one after the other, (using macros) then compares each one to 5 pictures it already has, bubt each screenshot taken, has a different set of pictures it is compared to, to the other 3 screen shots. My problem is, how to do this, because the method is the same, but i dont want to have four lots of code, there must be a way of doing this...

Copyright © 2005-08, All rights reserved