code for changing every value with multiple criteria

orimpila

New member
Local time
Today, 02:34
Joined
Jun 7, 2013
Messages
5
Hello! I made this code in excel, and I'd love to get it working in access.

Sub Satunnaisluvut()
Dim OmaAlue As Range
Dim Solu As Range
Set OmaAlue = Range("A1:A5")
For Each Solu In OmaAlue
If Solu.Value = "aa" Then
Solu.Value = "bb"
End If
Next Solu

End Sub

How do i set the wanted field? And how about the loop? My boss just assumed if i know excel i know acces :/
 
Hello yourself,

that assumption is painful. Access handles data differently, and you use ID's or other means to refer to field values.

Some of the folks here should be able to address you to some decent readings in order to clear this up for you, I would advice you use a query to do this, without any code.
 
orimpila, First Welcome to AWF.. :)

I in one way agree to MikeLeBen's comment.. However I do not agree with how he has expressed it.. Your description is quiet vague.. Is it possible if you could give another shot at explaining what is your exact problem? Are you trying to change values in an Excel workbook from Access application? More information is required to give assistance..
 
Are you new to Access? You can use the Replace function. To do so in a query would require you to run an Update query.

Code:
UPDATE Table1 SET Table1.Solu = Replace([Solu],"aa","bb");
 

Users who are viewing this thread

Back
Top Bottom