View Full Version : Setting the Default Value as the value in another field


wozza
09-22-2003, 01:42 AM
Helllo,

I wish to make the default value for a field the same as another field in the same table. eg for a simple forum database:

PostID AutoNumber (Primary key)
DiscussionID Number
...

I want the DiscussionID field to be the same as the PostID autonumber as default. This means that the record is the first post in a new discussion. If the record is a reply to another post then the DiscussionID is entered as the PostID of the original message.

I need the default value for the DiscussionID field to be entered at the table level as I am using a web interface to access the database not Access forms. I have tried putting =[PostID] into the default value for DiscussionID but it gives me an error like 'The database engine does not recognise the field 'PostID' in a default value'.

How do I make the default value for DiscussionID the same value as PostID?????

wozza
09-22-2003, 06:39 AM
Nevermind people. I realised what I was trying to do is impossible in Jet so I derived the values I wanted when I call the data in SQL. Used the code:
IIF(isNull([DiscussionID]), [PostID], [DiscussionID])
to achieve my desired information.