Freedom Computers

ACCESS

Generally useful scripts snippets. Refer to fields in subforms

' Put the name of this macro "Maximize" in the On Open Event on the MAIN form top automatically maximise the screen for the whole of the application
DoCmd.Maximize
**********************************************************************************
Place this in Unload event
' Close Down Access
Dim R As Long
R = MsgBox("Are you sure you want to quit Access?", vbQuestion + vbYesNo, " ")
If R = vbNo Then
Cancel = True
Exit Sub
Else
Application.Quit 'Rem out this line when developing
End If
********************************************************************************
File Handling - Get First Record from another table

Dim dbase As DAO.Database
Dim recdset As DAO.Recordset

Set dbase = CurrentDb
Set recdset = dbase.OpenRecordset("t-vat")

If IsNull([VAT]) Then
recdset.MoveFirst
[VAT] = recdset![VATRate]
End If
********************************************************************************
To refer to a field in a Higher Subform
Forms![TopFormName]![Lowersubformname].form!{fieldname]
********************************************************************************