This doesn't seem like it should be complicated, but for some reason I'm not figuring it out.
I just want to update a field in a table based what is found in another field in another table.
So, I have a Public Function with a Select Case statement. Then I'm trying to call to that function in the "Update To" field of an update query.
I'm having a hard time trying to find the proper Syntax to do this.
After Public Function.....do I want to first put the field that I'm updating, or the field that I'm looking at to determine what to update to?
In the following (very rough) example, Description would be a field in the "ItemsOrdered" table, and Product would be the field that I want to update in the "Contracts" table. The tables are joined (1 to many), and in the Criteria row for the Product field I have "Unassigned".
EX. Public Function Product(Description As String) As String
Select Case Description
Case "Advance"
Product = "Honors"
Case "Other"
Product = "Alternate"
Case Else
Product = "Unknown"
End Select
Then in the query, the only column I would have is the Product field from the "Contracts" table, and in the Update To field it is Productxxxx???
I believe in the update to field it should be FunctionName(Product) for this example. But that doesn't seem to work.
Or do I need to set the table name for where Description is somewhere in the Function?
Or maybe a Do While Product = "Unassigned" type of loop? Although I was thinking that this would be covered by putting that in the criteria of the query.
Any examples or references would be GREATLY appreciated! I think I just need to see it in use to get myself on the right track. I'm not finding any posts, or references anywhere to a Select Case statement being used when the fields are in 2 seperate tables. And my attempts just to try it with fields in the same table (for testing) have resulting it the fields being updated to just Null or seemingly blank values. Although it does only update the records where Product = "Unassigned", so I guess I've got that part right!
I just want to update a field in a table based what is found in another field in another table.
So, I have a Public Function with a Select Case statement. Then I'm trying to call to that function in the "Update To" field of an update query.
I'm having a hard time trying to find the proper Syntax to do this.
After Public Function.....do I want to first put the field that I'm updating, or the field that I'm looking at to determine what to update to?
In the following (very rough) example, Description would be a field in the "ItemsOrdered" table, and Product would be the field that I want to update in the "Contracts" table. The tables are joined (1 to many), and in the Criteria row for the Product field I have "Unassigned".
EX. Public Function Product(Description As String) As String
Select Case Description
Case "Advance"
Product = "Honors"
Case "Other"
Product = "Alternate"
Case Else
Product = "Unknown"
End Select
Then in the query, the only column I would have is the Product field from the "Contracts" table, and in the Update To field it is Productxxxx???
I believe in the update to field it should be FunctionName(Product) for this example. But that doesn't seem to work.
Or do I need to set the table name for where Description is somewhere in the Function?
Or maybe a Do While Product = "Unassigned" type of loop? Although I was thinking that this would be covered by putting that in the criteria of the query.
Any examples or references would be GREATLY appreciated! I think I just need to see it in use to get myself on the right track. I'm not finding any posts, or references anywhere to a Select Case statement being used when the fields are in 2 seperate tables. And my attempts just to try it with fields in the same table (for testing) have resulting it the fields being updated to just Null or seemingly blank values. Although it does only update the records where Product = "Unassigned", so I guess I've got that part right!