Sub Name Variable (1 Viewer)

IanT

Registered User.
Local time
Today, 02:20
Joined
Nov 30, 2001
Messages
191
Hi

I am using the code below to look at a table to identify a sub name in a module that I want to run, but I get an error message saying Compile Error, expected sub. It looks like it is something to do with the sub name variable as I am using String. Can anyone help!

Sub Update()

Dim rNames As DAO.Recordset
Dim db As DAO.Database
Dim strSubNames As String


Set db = CurrentDb

DoCmd.Echo False
DoCmd.SetWarnings False


Set rsNames = CurrentDb.OpenRecordset("SELECT tblReportProduction.[Report Name], tblReportProduction.[Sub Name], tblReportProduction.Available, tblReportProduction.AutoNumber FROM tblReportProduction WHERE (((tblReportProduction.Available)=Yes));")


Do While Not rsNames.EOF


strSubNames = rsNames.[Sub Name]


Call strSubNames

Set db = Nothing

DoCmd.Echo True

rsNames.MoveNext

Loop

rsNames.Close

DoCmd.Echo True

End Sub
 

DJkarl

Registered User.
Local time
Yesterday, 20:20
Joined
Mar 16, 2007
Messages
1,028
You cannot use Call in the manner you are trying, use Eval or Run instead.
 

boblarson

Smeghead
Local time
Yesterday, 18:20
Joined
Jan 12, 2001
Messages
32,059
Do NOT use UPDATE as the name of a procedure. That is an Access Reserved Word and has special meaning. Use something else like rUpdate or whatever but not just Update.
 

Users who are viewing this thread

Top Bottom