Code Examples

Check Name

acCmdSelectAll

Checks whether a particular control name exists on a form.

'***************** Code Start *******************
'This code was originally written by Terry Wickenden.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.


Function TestNames(strFormName As String, strControlName As String) As Boolean

  On Error GoTo ErrHandler
  ' Turn the screen off while the function is running
  DoCmd.Echo False
  DoCmd.OpenForm strFormName, acDesign
  DoCmd.RunCommand acCmdSelectAll
  TestNames = Forms(strFormName)(strControlName).InSelection

SubExit:
  DoCmd.Close acForm, strFormName, acSaveNo
  ' Make sure that the screen displays properly
  DoCmd.Echo True
  Exit Function

ErrHandler:
  'An error will occur if the control is not in the selection
  TestNames = False
  Resume SubExit
End Function

'****************** Code End ********************

© 1998 - 2011 Terry Wickenden TKW Design Site developed, maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.