Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error: Expected: = 1

Status
Not open for further replies.

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:
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
 
Doh! That did it. Thanks for your help dhookom!
 
Another way:
Code:
Call formatlocations("Inventory_Snapshot", "Location")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top