View Full Version : Action query....replacing a field


kbrooks
11-26-2001, 11:22 AM
I have a basic table called ApplicationFunctions with 3 fields in it:
UserID
ApplicationID
FunctionID

I enter however many application/function combinations each user has access to, so there could be many records with the same UserID.

I want to be able to copy everything with a certain UserID and ApplicationID, and append it to the ApplicationFunction table only REPLACING THE ORIGINAL USER ID WITH ANOTHER USER ID. That way if several users have the same accesses, I don't need to enter 57 application/function combinations for each user.

Make sense? Thanks for any help you can give me.

Pat Hartman
11-26-2001, 06:38 PM
1. Open the QBE grid and add the ApplicationFunctions table.
2. Select the three columns.
3. Add "[EnterModelUserId]" without the quotes to the criteria field of the UserId field.
4. Change the query type to Append.
5. Select ApplicationFunctions as the AppendTo table.
6. Access will populate the AppendTo columns
7. Delete the value of the AppendTo cell for the UserId column
8. Add the UserId column a second time.
9. Change the value of the Field cell of the second UserId column to "[EnterNewUserId]" without the quotes.

You should end up with something in the following format:
INSERT INTO AccessAndJetErrors ( ErrorString, ErrorCode )
SELECT AccessAndJetErrors.ErrorString, [EnterToCode] AS Expr1
FROM AccessAndJetErrors
WHERE (((AccessAndJetErrors.ErrorCode)=[EnterFromCode]));

The query will prompt you for a Model user and then a New user. It will copy the rows of the Model user and append them with the New userID.

kbrooks
11-27-2001, 08:39 AM
Has anyone ever told you that you're absolutely amazing? I knew it was possible, but BOY this works slick! Thanks a lot!!! http://www.access-programmers.co.uk/ubb/smile.gif

Pat Hartman
11-27-2001, 07:04 PM
My granddaughters (2 year old twins) think I'm the cat's meow. They even clap when I sing. I don't think I'll quit my day job though. Thanks http://www.access-programmers.co.uk/ubb/smile.gif