Consulting

Results 1 to 3 of 3

Thread: setting a default value

  1. #1
    VBAX Newbie
    Joined
    Jul 2010
    Posts
    3
    Location

    setting a default value

    Hello guys,

    Got a slight problem and would need some help quickly, please.
    I m still working on a company tool for our storage management which is already working pretty well.

    On a Form i can work with all the datasets but here is the problem i got:
    Most datasets are not complete, which means that only a few data are defined and a few are empty.
    e.g. one dataset contains of: article number, amount of parts, price per part, storage position
    but on a few datasets there is only an amount of parts, a price per part and the storage position set, and the article number stays empty.

    Now i have a tool on that form, that lets me transfer a certain amount of a part (not necessarily all of them) to a different storage position.
    I solved this wih the following procedure:
    - I m looking up each value with Dlookup and write it on a string or integer.
    - I m doing the calculation for the new value of amount of parts
    - i m creating a new dataset with INSERT INTO and all values that didnt change and the new value for amount of parts

    If a dataset is complete, this procedure works well and without any problems.
    but if the dataset is incomplete, the Dlookup function cant look up a certain value and i get the error message.

    Now my question: Is there a way i can get my datasets a default value which will be taken in case that one part of my dataset is empty?
    If yes, how can i do that since setting a default value in my table somehow doesnt work.

    Thanks in advance

    Oliver

  2. #2
    What is the primary key for each record?

    Are you using an AutoNumber as the primary key?
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    VBAX Expert Imdabaum's Avatar
    Joined
    Jun 2006
    Posts
    652
    Location
    In your DLookup, you may want to use the NZ function,

    NZ(Dlookup("Amount", "Parts", "ID= " & Parts.ID), 0)
    If Amounts value is null, then you get 0.
    Someday I'll understand everything...
    Even then...I'll still pretend I'm a beginner.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •