Smoothcat74
Technical User
- Aug 29, 2008
- 40
Hi everyone,
I have a simple block of code that reformats the text in a specific field after importing an Excel spreadsheet. I set it up as a sub accepting 2 variables, but I when I try to launch the sub using the following:
formatlocations("Inventory_Snapshot", "Location")
I get "Compile Error: Expected: =" error.
Here is the code I'm using:
I have a simple block of code that reformats the text in a specific field after importing an Excel spreadsheet. I set it up as a sub accepting 2 variables, but I when I try to launch the sub using the following:
formatlocations("Inventory_Snapshot", "Location")
I get "Compile Error: Expected: =" error.
Here is the code I'm using:
Code:
Sub FormatLocations(strTableName As String, strFieldName As String)
Dim db As DAO.Database
Dim tblSelected As DAO.Recordset
Dim strFormatLoc As String
Set db = CurrentDb
Set tblSelected = db.OpenRecordset(strTableName)
With tblSelected
.MoveFirst
Do While Not .EOF
strFormatLoc = Left([strFieldName], 2) & Mid([strFieldName], 4, 1) & Mid([strFieldName], 6, 2) & Mid([strFieldName], 9, 4)
.Edit
!Location = strFormatLoc
.Update
.MoveNext
Loop
End With
End Sub