Re: Setting .DefaultValue causes Restart

From: Steve Schapel (schapel_at_mvps.org.ns)
Date: 07/06/04


Date: Wed, 07 Jul 2004 06:23:56 +1200

Larry,

You are using incorrect syntax. Please refer to my earlier post for the
correct syntax of the Default Value property setting. Please try this,
and post back if it doesn't give the desired results.

-- 
Steve Schapel, Microsoft Access MVP
Larry Jones wrote:
> In the Default property for this textbox, I put the following:
> =Nz(DMax("Order", "tblPersonnelLocation", "PersonnelID = " &
> Me.Parent.PersonnelID), 0) + 1
> 
> BUT, Access changes it to
> Nz(DMax("Order","tblPersonnelLocation","PersonnelID = " &
> [Me].[Parent].[PersonnelID]),0)+1
> 
> This change does not work (even in immediate mode) while the syntax I
> used does work (in immediate mode and in code anyway). The way Access
> changes it, gives me a ?#NAme error
> 
> I have to get PersonnelID from the parent form, because when a new
> location record is being created for the person on this subform, there
> is no PersonnelID on the new record, so I can't refer to it.
> 
> So I change the referenc to refer to the name of the parent form and
> that seems to work. BUT when I delete a location, I now get an error
> that says "can't find the field '|' referred to in your expression".  
> argh!
> 
> It goes ahead and deletes the record, but then increments the counter
> on the next "blank" record. So frustrating!