Edit field in Table VBA

Trevor G

Well-known Member
Joined
Jul 17, 2008
Messages
6,737
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
I am seeking to use a module sheet to create a sub/function to update a field if it meets certain criteria

I have a table called = "GDV_Rates_Conventional_Sum"

and I have a fields called "No_Of_Risks_Sum"

What I need to do is fill a field if the following occurs

number of No_Of_Risks_Sum is above 100 Then place in 1
number of No_Of_Risks_Sum is Between 50 and 100 Then place in 2
number of No_Of_Risks_Sum is Below 50 Then place in 3

The field to update is called Credibility


Any example would be greatly appreciated
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Use an expression in your form's BeforeUpdate event.
Code:
Select Case No_of_risks_sum
  Case <50
    Credibility = 3
  Case <100
    Credibility = 2
  Case Else
    Credibility = 1
End Select

Denis
 
Upvote 0
Use an expression in your form's BeforeUpdate event.
Code:
Select Case No_of_risks_sum
  Case <50
    Credibility = 3
  Case <100
    Credibility = 2
  Case Else
    Credibility = 1
End Select

Denis

Denis thank you,

I am aiming to use a module sheet in the VBA side rather than on a form, as it has to update all records in a table, I think I am looking at DAO and Edit recordset, but note sure of code, but I most certainly will consider asking if the case statement is acceptable.
 
Upvote 0
Trevor

Is this related to this thread?

If it is then please stick to one thread, and if you have any problems with any suggestions made then post them there.

Did you even try what I suggested?

I know it wasn't a perfect solution but I was only basing what I posted on the information you had provided so far.:)
 
Upvote 0
Go with Norie's suggestion. You will need to run an update query, which can just be coded in SQL. I suggest that you create the query as normal, copy the SQL to Notepad, delete the query, then use that SQL in the VBA expression.

Denis
 
Upvote 0

Forum statistics

Threads
1,214,992
Messages
6,122,631
Members
449,095
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top