Sorry for the late night post. I am midnight coding and need rest. After work tomorrow I will check post and keep truckin' on this project. Also sorry for code format. I had to manually type the code because the machine I am coding on is not connected to the internet.
I have learned the basic looping technique for going through a record set from the following link. I need to know if my logic is on the right track.
http://www.accessallinone.com/looping-through-a-recordset/
My question is a followup to a thread that was opened on this forum:
http://www.access-programmers.co.uk/forums/showthread.php?t=192793

I want to do the following:
1) Use record set looping technique to fix a variety of incorrect naming conventions to a standard format
2) Update the table (or create a new table) from the updated record set values. (Is my logic going to update the table selected in the code I used to dimension the record set or will I need to do something else to make the changes available for other tasks after record set is closed ? After the naming conventions are fixed this data will be available for excel automation that I am working on and posting questions on another thread in this forum. HAHA I'm going code BANANAS
)
3) rs.fields![fleetlocation] is used so many times, how can I make this a variable (what do I dimension the variable as?)
4) Use an AND statment with an if statment (how to do this with correct syntax)
Thanks for any help!
I have learned the basic looping technique for going through a record set from the following link. I need to know if my logic is on the right track.
http://www.accessallinone.com/looping-through-a-recordset/

My question is a followup to a thread that was opened on this forum:
http://www.access-programmers.co.uk/forums/showthread.php?t=192793


I want to do the following:
1) Use record set looping technique to fix a variety of incorrect naming conventions to a standard format
2) Update the table (or create a new table) from the updated record set values. (Is my logic going to update the table selected in the code I used to dimension the record set or will I need to do something else to make the changes available for other tasks after record set is closed ? After the naming conventions are fixed this data will be available for excel automation that I am working on and posting questions on another thread in this forum. HAHA I'm going code BANANAS

3) rs.fields![fleetlocation] is used so many times, how can I make this a variable (what do I dimension the variable as?)
4) Use an AND statment with an if statment (how to do this with correct syntax)
Code:
sub loopandfix()
on error goto errorhandler:
strSQL = "tblUnionQueryResults" 'table was created from a union query but has inconsistant naming conventions for the fleet location name
with rs
If not .bof and .eof then
.movelast
.movefirst
while (not .eof)
If rs.fields![fleetlocation] = "string resembling an inconsistency" then
rs.edit
rs.fields![fleetlocation] = "new value"
rs.update
end if
'#####another scenario where the if statment also has an AND statment
if instr(1,rs.fields![fleetlocation],"string to match")>0 AND instr(1,rs.fields![fleetlocation],"#")>0 then
rs.edit
rs.fields![fleetlocation] = "new value that will not add a # to fleet location "
rs.update
else
' no # in the fleet location name
'extract the text in the middle that causes naming convention inconsistency
'add a "#" before the fleet location number after fleet location name
end if
errorhandler:
error handling code
end sub