New Field that Pulls from Existing Field

Zorkmid

Registered User.
Local time
Today, 09:21
Joined
Mar 3, 2009
Messages
188
Hi all,

I want to create a new field that draws from another field in the same table. One possibility is "Near Miss" in the existing field. For every record where "Near Miss" is in the existing field, I want to have "Near Miss" in my new field. In all other cases I want "Actual Event".

Is there some kind of append query I can use to do this?
 
I don't think there is a need for duplicating data in the same record, in the same table? If you feel you do, then you should be thinking of "normalization". You can use queries instead to display this.
 
No, I want to remove "Near Miss" as a selection on the entry form under that field and have a new field for it. Near Miss is currently buried in a combobox where it doesnt belong.
 
Are you going to delete that old field after you've done this?

This would be a combination of an Update query and the IIF() function. Have you used these before?
 
No I haven't

And I dont plan on deleting the old field, just removing the option to select "Near Miss"
 
You can write code to disable that control if that value was selected.

If you still want to go ahead with your plan, then here is the format of an update query (based on your spec):

CurrentDb.Execute "UPDATE [TableName] SET [NewFieldName] = 'Near Miss' WHERE [ExistingFieldName] = 'Near Miss';"
CurrentDb.Execute "UPDATE [TableName] SET [NewFieldName] = 'Near Miss' WHERE [ExistingFieldName] <> 'Actual Event';"

First try it on a back-up copy. Put the right table name and field names and paste it into the On Click event of a command button.
 
Sounds like you need to do some reading Zorkmid:). Have a quick search on google for some quick tutorials.
 
You can write code to disable that control if that value was selected.

If you still want to go ahead with your plan, then here is the format of an update query (based on your spec):

CurrentDb.Execute "UPDATE [TableName] SET [NewFieldName] = 'Near Miss' WHERE [ExistingFieldName] = 'Near Miss';"
CurrentDb.Execute "UPDATE [TableName] SET [NewFieldName] = 'Near Miss' WHERE [ExistingFieldName] <> 'Actual Event';"

First try it on a back-up copy. Put the right table name and field names and paste it into the On Click event of a command button.


I think you mean:

CurrentDb.Execute "UPDATE [TableName] SET [NewFieldName] = 'Near Miss' WHERE [ExistingFieldName] = 'Near Miss';"
CurrentDb.Execute "UPDATE [TableName] SET [NewFieldName] = 'Actual Event' WHERE [ExistingFieldName] <> 'Near Miss';"


But I got the picture :)

THanks!
 

Users who are viewing this thread

Back
Top Bottom