Good Evening All,
My query involves a database that reserves and books out loan equipment to users. When The database was originally designed it took no account of users who as the result of marriage might change their surnames. This presents some issues when those users return under a different name.
I have created a search form that allows the administrator to check their surname against their userID number, then add the new surname into a new field called NameChange, within the user table. This part of the procedure went without incident, but I would like to take this a step further.
At the point of making the reservation, I would like to adjust the existing SQL query, to search staff accounts and update only those surnames that have been data inputted into the NameChange field. This would then reflect in the user search and update reservation and booking information.
The Reservation Form uses a query to search all users in the Tbl_Person ordered by surname. With the new field NameChange, the SQL runs OK as follows:
The code appends the new name in brackets to the maiden name. I would like it to replace the maiden name and was thinking that an IF/Else statement would do it. If so, I would be most grateful for any assistance writing it.
The statement would be along the lines...
This is my first go at SQL and I attempted to parse the above speculative code but it wouldn't go. If anyone can offer any advice and guidance that would be great.
Thanks in advance.
My query involves a database that reserves and books out loan equipment to users. When The database was originally designed it took no account of users who as the result of marriage might change their surnames. This presents some issues when those users return under a different name.
I have created a search form that allows the administrator to check their surname against their userID number, then add the new surname into a new field called NameChange, within the user table. This part of the procedure went without incident, but I would like to take this a step further.
At the point of making the reservation, I would like to adjust the existing SQL query, to search staff accounts and update only those surnames that have been data inputted into the NameChange field. This would then reflect in the user search and update reservation and booking information.
The Reservation Form uses a query to search all users in the Tbl_Person ordered by surname. With the new field NameChange, the SQL runs OK as follows:
Code:
SELECT tbl_Person.PersonID, [Surname] & "(" & [NameChange] & ")" & ", " & [Forename] & " (" & [PersonID] & ")" AS Name, tbl_Person.NameChange
FROM tbl_Person
ORDER BY tbl_Person.Surname;
The statement would be along the lines...
Code:
If Not Null [NameChange] then Select tbl_Person.ID,[NameChange]]& ")" & ", " & [Forename] & " (" & [PersonID] & ")" AS Name, tbl_Person.NameChange
FROM tbl_Person
ORDER BY tbl_Person.Surname;
Else Select tbl_Person.ID,[Surname]& ")" & ", " & [Forename] & " (" & [PersonID] & ")" AS Name, tbl_Person.NameChange
FROM tbl_Person
ORDER BY tbl_Person.Surname;
Thanks in advance.
Comment