I know Excel VBA but New to MS Access VBA...question re: creating function

yomero

Active Member
Joined
May 14, 2008
Messages
257
Hi, can you help me translate this function into VBA for MS access?
Totally new, I have tried withouth luck. Your help is much appreciated. Once I know whihc objects I need I could take it from there.

Table name: Data
Field1: Platform
Field2: Screenview

Code:
Function UpdateColumn

for each field in Table(Data).field1
 select case true
  case like '*xyz*'
     Field2 = 'GoodJob'
  case like 'WWW'
     Field2 = 'GreatJob'
end select
 
end function
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You wouldn't use code for something like that in Access, you'd use a query.
 
Upvote 0
You wouldn't use code for something like that in Access, you'd use a query.

I have about 4.cases. i am able to Update using a query, but only one case at a.time. What would.be the syntax in access to update all 4 cases in the same Update query?
 
Upvote 0
Like this.

UPDATE Data SET ScreenView = Switch(Platform Like '*xyz*', 'GoodJob', Platform Like 'WWW', 'GreatJob')
 
Upvote 0
Like this.

UPDATE Data SET ScreenView = Switch(Platform Like '*xyz*', 'GoodJob', Platform Like 'WWW', 'GreatJob')

I am getting an "UPDATE syntax error". Where am I wrong? Thx

UPDATE [RAW - Active]
SET [RAW - Active].Screentype = Switch ([RAW - Active].[Client Version]) Like '*iOS*','iOS', [RAW - Active].[Client Version]) Like '*Android*','Android', [RAW - Active].[Terminal Model]) Like '*Windows*','PC',[RAW - Active].[Terminal OS]) Like '*OSX*','MAC');
 
Upvote 0
You appear to have added an unneeded ) after the field name in the Switch statement.

UPDATE [RAW - Active] SET [RAW - Active].Screentype = Switch([RAW - Active].[Client Version] Like '*iOS*','iOS',[RAW - Active].[Client Version] Like '*Android*','Android',[RAW - Active].[Terminal Model] Like '*Windows*','PC',[RAW - Active].[Terminal OS] Like '*OSX*','MAC');
 
Upvote 0
Just to close this thread.

I created a query and with the Expression Builder I added Expressions in new columns such as:

Screen: IIf([00_Data]![Terminal Model] Like '*iPhone*','iPhone',IIf([00_Data]![Terminal Model] Like '*AndroidTablet*','Android_Tablet',IIf([00_Data]![Terminal Model] Like '*iPad*','iPad',IIf([00_Data]![Terminal Model] Like '*Windows*','PC',IIf([00_Data]![Terminal OS Version] Like '*OSX*','MAC','Android_SP')))))

With this query then I create another table that I use to do...everything else I need to do .

Thanks for your replies.
Yomero
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

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