Microsoft KB Archive/62832

= 7.00 CREATEINDEX Example Gives &quot;No Current Record&quot; at Run-Time =

Article ID: 62832

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft BASIC Professional Development System 7.1
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q62832



SUMMARY
Running the sample program on Page 73 of the &quot;Microsoft Basic 7.0: Language Reference&quot; manual returns a run-time error of 85, &quot;no current record,&quot; on the RETRIEVE statement.

The code should be changed as shown below for the program to run correctly.



MORE INFORMATION
The sample program found on Page 73 uses a file called BOOKS.MDB, the sample ISAM file that SETUP copies to your disk. However, in this program, the user-defined type, BookRec, does not match the record structure used in BOOKS.MDB. Also the program specifies a table name that does not exist in BOOKS.MDB.

The user-defined type, BookRec, should be defined as follows: TYPE BookRec IDNum AS DOUBLE Price AS CURRENCY Edition AS INTEGER Title AS STRING * 50 Publisher AS STRING * 50 Author AS STRING * 36 In addition, the table name should be defined as &quot;BookStock&quot; instead of &quot;BooksStock&quot;.

The corrected program is as follows: DEFINT A-Z TYPE BookRec                  'altered user-defined type IDNum AS DOUBLE Price AS CURRENCY Edition AS INTEGER Title AS STRING * 50 Publisher AS STRING * 50 Author AS STRING * 36 END TYPE

DIM Library AS BookRec DIM msgtxt AS STRING

CONST Database = &quot;BOOKS.MDB&quot; CONST TableName = &quot;BookStock&quot; 'TableName = BookStock (not BooksStock) TableNum = FREEFILE

OPEN Database FOR ISAM BookRec TableName AS TableNum CREATEINDEX TableNum, &quot;A&quot;, 0, &quot;Author&quot; CREATEINDEX TableNum, &quot;I&quot;, 1, &quot;IDNum&quot; CREATEINDEX TableNum, &quot;T&quot;, 0, &quot;Title&quot; CREATEINDEX TableNum, &quot;C&quot;, 0, &quot;Price&quot; SETINDEX #1, &quot;A&quot; CLS : LOCATE 13, 30 PRINT &quot;choose a key:&quot; PRINT SPC(9); &quot;move to:&quot;; TAB(49); &quot; order by: X &quot; PRINT : PRINT SPC(9); &quot;F - first record&quot;; TAB(49); &quot;A - Author&quot; PRINT : PRINT SPC(9); &quot;L - last record&quot;; TAB(49); &quot;I - ID number&quot; PRINT : PRINT SPC(9); &quot;N - next record&quot;; TAB(49); &quot;T - Title&quot; PRINT : PRINT SPC(9); &quot;P - previous record&quot;; TAB(49); &quot;C - Cost&quot; PRINT : PRINT SPC(9); &quot;Q - Quit&quot;; TAB(49); &quot;X- no order&quot; LOCATE 3, 1: PRINT TAB(37); Books; &quot;&quot; PRINT STRING$(80, &quot;-&quot;); VIEW PRINT 5 TO 10

MOVEFIRST TableNum DO CLS RETRIEVE TableNum, Library PRINT &quot;Author:  &quot;; Library.Author; PRINT TAB(49); &quot;ID #&quot;; Library.IDNum PRINT &quot;Title:     &quot;; Library.Title PRINT &quot;Publisher: &quot;; Library.Publisher PRINT &quot;cost:    &quot;; Library.Price PRINT SPC(30); msgtxt PRINT STRING$(64, &quot;-&quot;) IF GETINDEX$(TableNum) = &quot;&quot; THEN PRINT STRING$(15, &quot;-&quot;); ELSE PRINT &quot;index in use: &quot;; GETINDEX$(TableNum); END IF

validkeys$ = &quot;FLNPQATICX&quot; DO        keychoice$ = UCASE$(INKEY$) LOOP WHILE INSTR(validkeys$, keychoice$) = 0 OR keychoice$ = &quot;&quot; msgtxt = &quot;&quot;

SELECT CASE keychoice$ CASE &quot;F&quot; MOVEFIRST TableNum CASE &quot;L&quot; MOVELAST TableNum CASE &quot;N&quot; MOVENEXT TableNum IF EOF(TableNum) THEN MOVELAST TableNum BEEP: msgtxt = &quot;** at last record **&quot; END IF    CASE &quot;P&quot; MOVEPREVIOUS TableNum IF BOF(TableNum) THEN MOVEFIRST TableNum BEEP: msgtxt = &quot;** at first record **&quot; END IF   CASE &quot;Q&quot; EXIT DO   CASE ELSE VIEW PRINT LOCATE 13, 59: PRINT keychoice$; VIEW PRINT 5 TO 10 IF keychoice$ = &quot;X&quot; THEN keychoice$ = &quot;&quot; SETINDEX TableNum, keychoice$ MOVEFIRST TableNum END SELECT LOOP

VIEW PRINT DELETEINDEX TableNum, &quot;A&quot; DELETEINDEX TableNum, &quot;I&quot; DELETEINDEX TableNum, &quot;T&quot; DELETEINDEX TableNum, &quot;C&quot; CLOSE END

Additional query words: BasicCom SR# S900606-48

Keywords: KB62832

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.