Setting default values to Access table fields?

  • Thread starter Thread starter Chua Hean Hean
  • Start date Start date
C

Chua Hean Hean

Hi,

I'm a newbie in Access programming. Like to know if there is any similar
functionality/method like the NVL() in Oracle in Access? I have problem
setting a default value in one of the columns in my table.

Thanks in advance.

- Hean Hean
 
In table design view, select your field and put the efault value in the
corresponding property line in the properties box at the bottom left hand
corner.

HTH,
Nikos
 
WE certainly have the nz() function which is the same as the oracle nvl()


However, while we have the equivalent function, I have no idea what, or why,
or how this function would be related to default vales in a table? What
relation do they have?


if you are asking that you have a query and would like a null field to
return some other value, then you use the nz() function in your report, or
use it in a query.

Both Oracle and ms-access does have a function to change null values.
However, this solution or answer has very little to do with the default
value for a field in a table? We are not trying to set a default value here,
but simply substitute a value for a field when it is null. I don't see this
as a default value problem. I mean, what happens if a user removes the value
in a field, it will now be null, but this issue has nothing to do with
default value in the field now...does it? I am not trying to be a pest here,
but your subject line of default value seems un-related to the nvl()
function.

Anyway, the nz() should do the trick for you.

So, if you have a report, and want to replace the City field with some text
when it is null, you could place a text box on the report. Remember, make
sure the text box has a DIFFERENT name then the field in the query or access
does get confused. In our example, lets assume the City field. So, we could
place a text box on the report called txtCity. For the data source, you can
use:

=(nz([City],"n/a"))

So, for all blank cities, the report will show "n/a".

You can also use the nz() funtion in a query, and thus would not have to use
it in the report.

You can use something like:

select FirstName, nz(city,'n/a') as NCity from tblCustomers

However, I generally find it easer to use the nz() function in the report,
or even on a form that I make.
 
Back
Top