Fordraiders
asked on
Update a field based on supplied variable
I have a table called:
Rebate_Qualifier
3 fields:
Rebate_ID Entity_Value Qualifier_ID
"Entity_Value" will always have a value in the field.
I have 2 variables rb and ent
rb = SLS-000118-MAIN-A1-5-R1
ent = 5
The Rebate_Id is null
Qualifier_ID is null
Table example below:
What I need:
I need to update the Rebate_Id field with variable rb
I need to update the Qualifier_ID field with variable ent
Thanks
fordraiders
Rebate_Qualifier
3 fields:
Rebate_ID Entity_Value Qualifier_ID
"Entity_Value" will always have a value in the field.
I have 2 variables rb and ent
rb = SLS-000118-MAIN-A1-5-R1
ent = 5
The Rebate_Id is null
Qualifier_ID is null
Table example below:
Rebate_ID Entity_Value Qualifier_ID
AABAA
AABAA
AABAA
AABAA
What I need:
I need to update the Rebate_Id field with variable rb
I need to update the Qualifier_ID field with variable ent
Thanks
fordraiders
UPDATE Rebate_Qualifier SET Rebate_Id = rb, Qualifier_ID =ent WHERE SomeCriteria
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
dim dbs as database
dim rst as recordset
dim strsql as string
dim strPKValue as string
strPKValue = "AABAA" '<- the entity value you for the record you want updating
'This assumes entity value is unique in the table..
strsql = "Select * from Rebate_Qualifier where Entity_Value = '" & strPKvalue & "';"
set dbs = currentdb
set rst = dbs.openrecordset(strsql)
rst.movefirst
rst.edit
rst!Rebate_ID = RD
rst!Qualifier_ID = ent
rst.update
rst.close
set rst = nothing
dbs.close
set dbs = nothing
or you could code an update query with variables / functions and call that....
dim rst as recordset
dim strsql as string
dim strPKValue as string
strPKValue = "AABAA" '<- the entity value you for the record you want updating
'This assumes entity value is unique in the table..
strsql = "Select * from Rebate_Qualifier where Entity_Value = '" & strPKvalue & "';"
set dbs = currentdb
set rst = dbs.openrecordset(strsql)
rst.movefirst
rst.edit
rst!Rebate_ID = RD
rst!Qualifier_ID = ent
rst.update
rst.close
set rst = nothing
dbs.close
set dbs = nothing
or you could code an update query with variables / functions and call that....
ASKER
All good examples and thank you very much !!