Compile error:Method or data member not found

G

Guest

I am working on a program which was written in Ms Access 97 and since then
has been converted to Ms Access 2002. I remember that I got the error
message about missing reference of dao2535.tlb versaion3.5 when I did the
conversion. I got the Microsoft DAO 3.6 to take care of that problem.

But now I got the subject error message when I tried to run the program.
The program stopped at the ACCT_NUM of "pAcctNum = rstDonor.ACCT_NUM".



Private Sub VerifyDonorCriteria() ' GET DONOR'S SCHOLARSHIP CRITERIA
Dim aSwitches(24) As String
For iX = 1 To 24
aSwitches(iX) = " " ' clear the 24 switches
Next

Dim iMajorCnt As Integer
Dim db As Database
Set db = CurrentDb() ' GET DONOR
Set rstDonor = db.OpenRecordset("tDonorMaster", dbOpenDynaset)
sDonorArg = "Acct_Num = '" & txtAcctNum & "'" 'set the donor file to this
donor
rstDonor.FindFirst sDonorArg

pAcctNum = " " ' save these for the report
pAcctName = " "
pAcctNum = rstDonor.ACCT_NUM
pAcctName = rstDonor.ACCT_NAME


The recordset was defined as follows:

Option Compare Database ' THIS MATCHES A DONOR TO ITS STUDENTS - 2/2001
Option Explicit ' 2/2001 Changed birth city to VISA
Option Base 1 ' sets 1st element of array to 1
Public rstDonor As Recordset

I changed the recordset to read DAO.recordset but it did not get rid of the
error message.

I am not sure if this has anything to do with the problem: the table
'tDonorMaster' is residing in a separate mdb and is linked to this program
mdb.

Thank you in advance.
 
W

Wayne Morgan

You were correct to change the Public statement to DAO.Recordset instead of
just Recordset. You may also try changing the Dim statement for db to
DAO.Database.

To get rid of the error, first check for spelling errors. After that, try a
! instead of a .

pAcctNum = rstDonor!ACCT_NUM
 
G

Guest

Thank you, Wayne. Changing "." to "!" worked. What is the difference
beween them two anyways?

Also, now I got the error message "no current records". The programs stopped
at "rstMatch.MoveFirst".

Private Sub ResetMatchFile() ' DELETE ALL RECORDS IN THE PREVIOUS FILE
Dim db As DAO.Database
Dim rstMatch As DAO.Recordset

Set db = CurrentDb() ' OPEN THE MATCH FILE
Set rstMatch = db.OpenRecordset("tDonorStudMatch", dbOpenDynaset)
' DELETE THE PREVIOUS RECORDS
rstMatch.MoveFirst
Do Until rstMatch.EOF
rstMatch.Delete
rstMatch.MoveNext
Loop ' Do while cnt < max
rstMatch.CLOSE


Thank you.
 
W

Wayne Morgan

The . is a property or method of the object. The ! will pass the 'subvalue'
of the default property. In this case, it is shortening
rstDonor.Fields("ACCT_NUM") to rstDonor!ACCT_NUM. There is probably a better
explanation. In most Access objects, you can use either for many things. The
advantage of the . is you get Intellisense to help you type. However, there
are times that you will still run into a problem. One common one is that to
use the . for a field after the Me keyword, you need to have a control on
the form bound to the field you are referring to. If you refer to a field
that doesn't have a control on the form, you need to use the !.

For the "No current record" error, I suspect that there is nothing to
delete, the recordset is empty already. You aren't checking for BOF and EOF
prior to attempting the move. However, there is another way around this.
Stepping through each record one at a time using DAO then deleting it is
going to be very slow. If you want to delete all records, the following will
be much faster.

strSQL = "Delete * From tDonorStudMatch;"
CurrentDb.Execute strSQL, dbFailOnError

This will delete all records in tDonorStudMatch and if there are no records
to delete, it will just continue happily along. It is also almost
instantaneous compared to stepping through each record using DAO.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top