469,270 Members | 1,097 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

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
Dec 22 '09 #1
2 4800
RuralGuy
375 Expert 256MB
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")
Dec 28 '09 #2
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.CancelEvent
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
Jan 4 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Eric Ellsworth | last post: by
1 post views Thread by Andrew Arace | last post: by
49 posts views Thread by Yannick Turgeon | last post: by
6 posts views Thread by Tim K. | last post: by
4 posts views Thread by The Facilitator | last post: by
5 posts views Thread by simon.robin.jackson | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.