need help with an Access onLoad event procedure

I’ve got this form in an Access database into which people enter data, but only once a day. Basically it records their login, date, and one or two other pieces of data that they type in.

What I need is an event proceudure that checks the table to see if data has already been entered by that agent for that day, and if it does, close the form and open a different form instead. Now I know I’ve done this before…in fact, I’ve got a functioning database where it works. But this is the event procedure that’s in that form, and I can’t figure out why it works:

Private Sub Form_Load()

If validation.Value = GetLoginName() Then
DoCmd.OpenForm “Menu”, acNormal

DoCmd.Close acForm, "DataEntryForm", acSaveNo

Else
DoCmd.GoToRecord , , acNewRec
End If

End Sub

It definitely works, but when I try to copy the code over to a different database, I get an error around the validation.Value. So I know I figured this out, probably five or six years ago, but I can’t remember how, and even stealing the old code for the new database doesn’t work. I don’t have any objects named ‘validation’, in either database, so I’m not sure what validation.Value refers to.

Anyone have experience with this that can help me out? I’ve been away from Access for quite a few years now, but the boss wants this done in Access so I’m stuck trying to remember it all.

Geeze it’s been forever, but I think every field on a form has a validation rule and probably an associated validation property.

he best advice I can give you is to ask at the UtterAccess forums. Those guys know everything.

validation.Value implies that there is a control named “validation”, probably a textbox.

ValidationRule and ValidationText are built-in properties of controls, but “validation” is not… you have to have something named “validation”, and that something has a property “value” otherwise you get a syntax or a run-time error.

Ensure “Option Explicit” is set so that the compiler will check for legit names prior to running the code.

In your old database that works, try right-clicking on “validation” and select Definition. That might lead you to what/where it is so you can replicate it in your new database.