RE: manually incrementing number code does not work in a2003



I tried the code, and it works, the only thing I can think of is that the
Dmax returns a null.
Open the Immidiate widow, and check what the Dmax returns

?DMax("Estimate_Number", "Table1")

--
Please respond to the group if your question been answered or not, so other
can refer to it.
Thank you and Good luck



"wellssh" wrote:

> I just noticed one other difference, at work -- SP1 has been installed, maybe
> a flaw in the service pack ?
>
> "Ofer" wrote:
>
> > Mybe, and sorry if it will sound like a silly question, but does the dmax is
> > looking in a table called Table1, but are there any records in this table?
> >
> > --
> > Please respond to the group if your question been answered or not, so other
> > can refer to it.
> > Thank you and Good luck
> >
> >
> >
> > "wellssh" wrote:
> >
> > > I tried the added code you suggested, and the value returned remains as
> > > ES-00001 and will not increment by 1
> > >
> > >
> > >
> > > "Ofer" wrote:
> > >
> > > > Does it return any value?
> > > > If it doesn't, try this incase the field is empty and not Null
> > > >
> > > > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > > > If IsNull(Me!Estimate_Number) Or Trim(Me!Estimate_Number)="" Then
> > > > Me!Estimate_Number = "ES-" & (Format(CLng(Right(Nz(DMax("Estimate_Number",
> > > > "Table1"), 0), 5) + 1), "00000"))
> > > > End If
> > > >
> > > > End Sub
> > > >
> > > >
> > > > --
> > > > Please respond to the group if your question been answered or not, so other
> > > > can refer to it.
> > > > Thank you and Good luck
> > > >
> > > >
> > > >
> > > > "wellssh" wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > I am trying to write the code to increment a number with 2 alpha characters
> > > > > and a dash in front as follows ES-00001. The number should increment by one
> > > > > each time the user inputs a new record using the form.
> > > > >
> > > > > I am using the following code, and it works great when tested on a db
> > > > > created in A2000. However will not increment at all when using in a db
> > > > > created in A2003 SP1
> > > > >
> > > > > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > > > > If IsNull(Me!Estimate_Number) Then
> > > > > Me!Estimate_Number = "ES-" & (Format(CLng(Right(Nz(DMax("Estimate_Number",
> > > > > "Table1"), 0), 5) + 1), "00000"))
> > > > > End If
> > > > >
> > > > > End Sub
> > > > >
> > > > > Is there additional code needed to make it work for A2003?
> > > > >
> > > > > Thank you in advance
> > > > >
> > > > > Sherman Wells
> > > > >
.



Relevant Pages