Hey guys, can an if statement be used to parse/split a name in SQL? I'm assuming it would be quicker than VBA. Here's my current code:
Also, can I pass in a variable to an update query? Such as a date I retrieved earlier and stored in a VBA variable.
Code:
' My major worry is that this could be a lot quicker if done in SQL, but that is very complex to design
Do Until .EOF
' This block splits the advisor's name
wholename = rsTempTable!agentname
'if there is a comma in the name
If InStr(wholename, ",") <> 0 Then
.Edit
rsTempTable!AdvisorLastName = Left(wholename, InStr(wholename, ",") - 1)
rsTempTable!agentname = Right(wholename, Len(wholename) - InStr(wholename, ",") - 1)
.Update
Else ' There is no comma, presume a company name, stored in AdvisorAdvisorLastName field
.Edit
rsTempTable!AdvisorLastName = rsTempTable!agentname
rsTempTable!agentname = ""
.Update
End If
Also, can I pass in a variable to an update query? Such as a date I retrieved earlier and stored in a VBA variable.