MS Access forms : spaces in table names & fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • grinder332518
    New Member
    • Jun 2009
    • 28

    MS Access forms : spaces in table names & fields

    My table is called "table A".
    There is a date field in this table called "1st Date Issued".

    My Form accesses this table, and I would like to write an expression which looks at all the entries in my table, and if "1st Date Issued" is more than 14 days ago, then to bring up a MsgBox.

    I thought I would use an 'On Enter' event procedure, like

    If [table A].[1st Date Issued] < (Date - 14) Then
    Call MsgBox("OnEnter :- Date is before 14 days ago")
    Cancel = True
    Exit Sub
    End If

    But this gives me syntax errors.

    I am new to Access, and all the training I have done has tables and fields without spaces in them.

    Can someone give me the correct syntax please ?
    And is the 'On Enter' event procedure the best way to handle this ?

    Many thanks
  • RuralGuy
    Recognized Expert Contributor
    • Oct 2006
    • 375

    #2
    Assuming the [Table A] is the RecordSource of your form then you don't include the table name in the reference.
    If [1st Date Issued] < (Date - 14) Then
    .
    What is it you want to do after you display the MsgBox? ... No Call BTW.
    MsgBox("OnEnter :- Date is before 14 days ago")

    Comment

    • grinder332518
      New Member
      • Jun 2009
      • 28

      #3
      MS Access forms : spaces in table names &amp; fields

      Thanks RuralGuy
      I ended up with this :

      Private Sub Form_Current()

      If Me.[1st Date Issued].Value < Date - 14 Then
      MsgBox ("Date is before 14 days ago")
      MsgBox ("Enter 2nd Letter Date NOW")
      DoCmd.CancelEve nt
      Me.Undo
      Else
      Exit Sub
      End If

      End Sub


      So I just use the msgbox as a warning,
      and let the user manually enter the 2nd date.

      Best Regards

      Comment

      Working...