Re: Creating an Orders Form with multiple order types

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



JP,

Thank you for the information, and I understand that I cannot use the
autonumber function, but I need sequential number for each type of order. I
have the ComboBox for the OrderTypes. I am going to have to do some research
the DMAX function. If you know if any samples that I can look at please let
me know.

Also you mention that I need to make sure there is no "Null" value... what
if I set my initial value to "0" or "1", then there wouldn't /couldn't be a
"null" value. Correct?


Thanks,

Brook

"JP" wrote:

> If you really want the order numbers to be separate by order type (i.e., the
> same order number can appear across order types but not within order types)
> then you cannot use an autonumber field.
>
> In that case, put an order type combo box or option group on your form. In
> the Before Update event for the form, put in code that does a DMAX on the
> order number field for that order type and then increment the result by 1 to
> make it the order number of the order being entered.
>
> You of course have to test to make sure that the user selected the order
> type before you can run the DMAX. You also have to have some code to test
> for a null result from the DMAX, which is what you'll get when entering the
> very first record for each order type. And, you'll have to have some code
> to make sure that you only try to set the order number on new records (set a
> flag if me.newrecord is true in the On Current Event). The order number
> field could not be the primary key because it is not unique (presumably the
> combination of the order type and order number could be the primary key).
>
> A lot of work.
>
> Or, you can simply use an autonumber field and make the order number unique
> across all order types. I would argue that's a better approach because this
> way you can never have any confusion caused by two different orders with the
> same order number (even if they are different order types).
>
>
> "Brook" <Brook@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:BC2A9FCE-885B-4314-98E2-4D0DE0E720EB@xxxxxxxxxxxxxxxx
> > Good day,
> >
> > What I have is this: tblorders (which houses all my orders - Custom
> (CST),
> > Stock (STK), and Sample (SPL). within the tblorders I have an "orderstype"
> > and "ordernumber".
> >
> > What I am trying to do is this: create either a Combo box or an option
> > group on my form, so that when I choose the appropriate order type, that
> type
> > code is saved in the "ordertype" field in my table, and the "ordernumber"
> for
> > that type is increased / incremented by 1.
> >
> > Any Ideas / suggestions?
> >
> > thanks,
> >
> > Brook
>
>
>
.



Relevant Pages

  • Re: Autonumber upon opening a form
    ... As to moving to the Child record, ... Roger's example uses DMax; as an aside I don't quite get the ... I've changed the field in the database from Autonumber to a text ... Data entry forms are for entering new data. ...
    (microsoft.public.access.forms)
  • Re: do all primary keys use autonumber
    ... that you won't have any duplicate values, and an Autonumber field occupies only about 4 bytes per record, much shorter than many other fields you might choose to use. ... choice of first resort, because it satisfies the requirements for a primary key, is small, and is not bound to anything else in the model, making it practically immune to any need for revision). ... Say, a table with just two columns, a random integer column named ID ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Selecting Records in a query
    ... perfectly due to problems using the "Autonumber" field. ... enter the "Period" I want but using a variation of your suggestion worked. ... You can get that with the DMAX function of with a subquery. ... >> and the data from the last 6 months in three separate reports. ...
    (microsoft.public.access.queries)
  • Re: "Indexed or Primary Key cannot contain a Null value" / Autonum
    ... Allen Browne - Microsoft MVP. ... Tips for Access users - http://allenbrowne.com/tips.html ... >> c) Is there any Default Value in the text box for the autonumber field>> on ...
    (microsoft.public.access.modulesdaovba)
  • Re: "Indexed or Primary Key cannot contain a Null value" / Autonum
    ... CaseAutonumber ... Allen Browne - Microsoft MVP. ... post the exact error message you are receiving. ... Is there any Default Value in the text box for the autonumber field ...
    (microsoft.public.access.modulesdaovba)