Re: orders form... using DMAX to assign new order number

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,
>From the info in your post, I would say to put the code in the cboordertype AfterUpdate event.
No, it should definitely not be an autonumber.

I can only guess at how you want it to work, so, post more info.
Did the code fail? If so, what line?

I'm also assuming that each ordertype is treated seperately as far as order numbers go.
Is that correct?

The code I gave you places the new number in a variable, you have to do something with that.

--
HTH
-------
Dan Artuso, MVP


"Brook" <Brook@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:BB906C61-005E-4AFF-93B6-A7170A39E4C3@xxxxxxxxxxxxxxxx
> hello... I have tried your suggested code, but was unable to get it to work
> the way that I would like..
>
> Should my ordernumber in my tblorders be an "Autonumber"?
>
> Do I need to add the code to the afterupdate?
>
> Thanks,
>
> Brook
>
> "Brook" wrote:
>
> > Thank you very much Dan,
> >
> > I am going to try this and see how it goes... I will post a response one
> > way or another.
> >
> > Brook
> >
> > "Dan Artuso" wrote:
> >
> > > Hi,
> > > Something like this maybe?
> > >
> > > dim lngOrderNumber as Long
> > >
> > > lngOrderNumber = DMax("[ordernumber]", "tblorders", "ordertype = '" & Me.cboordertype & "'") + 1
> > >
> > > --
> > > HTH
> > > -------
> > > Dan Artuso, MVP
> > >
> > >
> > > "Brook" <Brook@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:23DB32DB-EF5B-412E-86F2-5C3F5231879A@xxxxxxxxxxxxxxxx
> > > > Good Day,
> > > >
> > > > I have have a form (frmneworders) that is based on my tblorders. The fields
> > > > are ordernumber, ordertype(based on cboordertype) for Custom, Program, or
> > > > Sample, and orderdetails.
> > > >
> > > > What I want to set up is this: When the user selects a new order, they will
> > > > choose the ordertype form the cboordertype, and after that ordertype is
> > > > selected I need to know how to create the code to lookup the DMAX for the
> > > > ordernumber and add 1 too it, to create a sequential ordering system for each
> > > > type of order.
> > > >
> > > > If anyone has any ideas... tips please pass them along...
> > > >
> > > > Thanks in advance..
> > > >
> > > > Brook
> > >
> > >
> > >


.



Relevant Pages

  • Re: orders form... using DMAX to assign new order number
    ... Private Sub cboordertype_AfterUpdate ... Brook ... "Dan Artuso" wrote: ... > From the info in your post, I would say to put the code in the cboordertype AfterUpdate event. ...
    (microsoft.public.access.formscoding)
  • Re: Problems with Autonumber
    ... Dan Artuso, Access MVP ... > from the Autonumber primary key. ... >> Unlike Excel, it shouldn't matter 'where' in the table you insert it because there ... >>> it's ridiculous to have that as a primary key. ...
    (microsoft.public.access.gettingstarted)