Avatar of Fordraiders
FordraidersFlag for United States of America

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:
Rebate_ID	Entity_Value	Qualifier_ID
	                AABAA	
	                AABAA	
	                AABAA	
	                AABAA	

Open in new window


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
Microsoft AccessVBA

Avatar of undefined
Last Comment
Fordraiders
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

UPDATE Rebate_Qualifier SET Rebate_Id = rb, Qualifier_ID =ent WHERE SomeCriteria

ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
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....
Avatar of Fordraiders
Fordraiders
Flag of United States of America image

ASKER

All good examples and thank you very much !!
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo