PDA

View Full Version : setting a default value



v1ech
08-04-2010, 03:31 AM
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

HiTechCoach
08-04-2010, 09:23 AM
What is the primary key for each record?

Are you using an AutoNumber as the primary key?

Imdabaum
08-04-2010, 09:42 AM
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.