Last updated: before December, 1998
'Written by Jerry Sikes, 1996 '(C) Copyright 1996 by Jerry Sikes ' 'Permission is granted to freely copy this script in electronic form, 'or to print for personal use. It may be use in any Approach database, 'but may not be distributed for profit either by itself or as part of 'a collection or database. ' 'Disclaimer: This script is provided as is without any express or implied 'warranties. The author assumes no responsibility for errors or omissions, 'or for damages resulting from the use of the information contained herein In my invoicing application, it is necessary to assign a serialized invoice number when the invoice is billed. The invoice record was created when the order was taken. If this was a make to order job, it could be 1 week per operation before it is ready to bill. I created an invoice number log table with the following fields;inv_no1(serial increment);sub_number(join field with invoice record-unique to each invoice) plus fields with creation formulas to set account number,po number, bill and ship name from the invoice record table. On my main data entry screen, I did not want to leave a fieldbox from the join table, that could accidently be focused on. Accidental click or tab would create a new record in the join table. So I hid it behind a text box and took it out of the tab order. I attached this script to the invoice record inv_no fieldbox. Sub Gotfocus(Source As Fieldbox) If currentview.body.inv_no.text ="" Then 'Checks if an invoice number is already assigned If currentview.repeatingpanel.ITEMNO.TEXT="" Then 'Checks if repeating panel(invoice line items) has at least one item Messagebox "Invoice not ready",MB_OK + MB_ICONSTOP,"Finish Invoice" Else If source.inv_date.text<>"" Then 'Forces user to enter invoice date prior to assignment of invoice number currentview.body.inv_no1.SetFocus 'This moves focus to the hidden empty field from invoice number assignment table 'Approach, by definition, creates a new record in the join table when 'typing into an empty join field currentview.body.inv_no.text=currentview.body.inv_no1.text 'new invoice number is set in invoice record from hidden join field currentview.body.terms.SetFocus 'moves focus to invoice terms field Else Messagebox "Enter Invoice Date", MB_OK + MB_ICONEXCLAMATION, "Invalid Date" currentview.body.inv_date.SetFocus End If End If Else Messagebox "Invalid Operation" , MB_OK + MB_ICONEXCLAMATION, "INVOICE NUMBER ALREADY EXISTS" End If End Sub I've sent this script to show syntax use of currentview.body.objectname.text The ".text" syntax is used regardless if the field type is text, numeric or date. If you want to manipulate a numeric field with a mathematical operation, then use Val(currentview.body.numeric_field_object_name.text)*0.6. Date fields have similiar script operators. If your object name(field name) is two words use a ~(tilde) in place of the space. currentview.body.Account~Number.text Jerry Sikes Unisource Converting