Access 97 conversion to 2000 and OpenRecordSet

G

gw

We have a simple application developed in Acees 95 / upgraded to 97 and now
we wish to move to 2000. the application 'almost' upgrades itself apart from
a problem we are havinng with OpenRecordSet .

The code is simple and I know (with hindsight) it can be much neater but
when you do not spend a great deal of time and it works then leave alone.

Code throws up Run Time eror 13 at the OpenRecordset command when run. Have
read lots of docs but confused as to change this seems a major problem. Have
checked DAO 3.6 to get round other problems and they seem to work.

Help appreciated



Public Function check_cust_number()
Dim no_string As String * 4
Dim iRec_count As Long
DoCmd.OpenQuery "sales_ledger_by_account_ref"
Set mydb = CurrentDb
Set Imp_table = mydb.OpenRecordset("sales_ledger_by_account_ref") ****
error line
Do Until Imp_table.EOF
iRec_count = 1
If Forms![job_log]![cust_number] = Imp_table("ACCOUNT_REF") Then Exit Do
Imp_table.MoveNext
iRec_count = 2
Loop
If iRec_count = 1 Then
Forms![job_log]![cust_name] = Imp_table("NAME")
Forms![job_log]![deliv_name] = Imp_table("NAME")
If Imp_table("ADDRESS_1") <> "" Then Forms![job_log]![deliv_address_1] =
Imp_table("ADDRESS_1")
 
P

Peter Russell

I can't see where you are declaring your recordset.

But you need to declare it explicitly as a DAO recordset.

Dim rs as dao.recordset.

Peter Russell
 
H

HelpfulIhope

Seems you need to declare an SQL recordset...also, built-
in functions from oler versions, such as OpenDynaset and
OpenRecordset have been replaced with RecordsetClone...but
that's a whole different ball of wax...so first the
recorset..

dim strSQL AS String
dim recMySet AS Recordset

strSQL = "SELECT MyTable.* FROM MyTable;"
recMySet = strSQL.RecordsetClone

set recMySet = CurrentDB().recMySet

now...sky's the limit
-----Original Message-----
We have a simple application developed in Acees 95 / upgraded to 97 and now
we wish to move to 2000. the application 'almost' upgrades itself apart from
a problem we are havinng with OpenRecordSet .

The code is simple and I know (with hindsight) it can be much neater but
when you do not spend a great deal of time and it works then leave alone.

Code throws up Run Time eror 13 at the OpenRecordset command when run. Have
read lots of docs but confused as to change this seems a major problem. Have
checked DAO 3.6 to get round other problems and they seem to work.

Help appreciated



Public Function check_cust_number()
Dim no_string As String * 4
Dim iRec_count As Long
DoCmd.OpenQuery "sales_ledger_by_account_ref"
Set mydb = CurrentDb
Set Imp_table = mydb.OpenRecordset
("sales_ledger_by_account_ref") ****
error line
Do Until Imp_table.EOF
iRec_count = 1
If Forms![job_log]![cust_number] = Imp_table ("ACCOUNT_REF") Then Exit Do
Imp_table.MoveNext
iRec_count = 2
Loop
If iRec_count = 1 Then
Forms![job_log]![cust_name] = Imp_table("NAME")
Forms![job_log]![deliv_name] = Imp_table("NAME")
If Imp_table("ADDRESS_1") <> "" Then Forms![job_log]! [deliv_address_1] =
Imp_table("ADDRESS_1")



.
 
Top