Slez,
Let's take a step back and regroup. I'm getting a bit confused about the details.
You wrote...
> there may be some confusion though. The error message lists "Test Project"
> **which is the value in the field ProjectName.**
Is ProjectName still a combo??
My solution does not involve a combo box...
Just a text control named "ProjectName", bound to the ProjectName field in tblProjects
(my example name/s)
When the user enters a ProjectName, and using the BeforeUpdate event, that entered
value is "looked up" against the ProjectName in the existing tblProjects table to see If
it's a duplicate or not.
If it is, the user is warned with a MsgBox, and with the Yes/No button on the MsgBox,
the user can allow that duplicate name (with a different ProjectID of course) to be
entered, or if not, the process is cancelled, and the ProjectName on the form is reset to
Null or it's original value.
So... given those conditions, this BeforeUpdate code should work to identify a dupe...
If Not IsNull(DLookup("[ProjectName]", "tblProject", "ProjectName = " &
[ProjectName]))
or
If Not IsNull(DLookup("[ProjectName]", "tblProject", "ProjectName =
Forms!frmYourFormName!ProjectName"))
If this doesn't work then post all the details (exact names and setup) about your
form, your form field, and your table.
*** Note: Spaces in data "values" is... of course... OK. But, we must know if any of the
form or control elements of the BeforeUpdate code contains spaces.
--
hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
"Slez via AccessMonster.com" <u23064@uwe> wrote in message news:6afecbe06f262@uwe...
>I tried bracketing, but that did not change the error received. I think
> there may be some confusion though. The error message lists "Test Project"
> which is the value in the field ProjectName. I do not use spaces in my field
> names, but the values can contain spaces, otherwise the user would be having
> to enter - StJudeHospital or TheSmithCompany, which wouldn't be right.
>
> If you have any other ideas that may help the problem, I'll appreciate it!
> Thanks for your help so far!
> Slez
>
>
>
> Al Campagna wrote:
>>Slez,
>> Yes, I did miss a Parens at the end of the DLookup. One of the hazards of email
>>coding.
>>------------
>> Yes, if the combo field on the form is named "Test Project" then it will have to be
>>bracketed.
>>
>>If Not IsNull(DLookup("[ProjectName]", "Project","ProjectName = " &
>>> [Test Project])) Then
>>
>> This is the reason why names with spaces should be avoided. No space names do not
>>require bracketing.
>> Try TestProject or Test_Project or just bracket.
>>------------
>> You can always add a Yes No button to the BeforeUpdate MsgBox, that would allow the
>>user to duplicate a ProjectName if necessary.
>> Yes = Keep the dupe name.
>> No = Cancel=True and TestProject.Undo... to kill the entry and retry another name.
>>
>>> Thanks for the reply! I didn't want to go the route of the other reply
>>> because there could be a duplicate name. My main purpose is to just alert
>>[quoted text clipped - 31 lines]
>>>>> Suggestions are appreciated!
>>>>> Slez
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...forms/200612/1
>