Sub Name Variable

IanT

Registered User.
Local time
Today, 19:40
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
 
You cannot use Call in the manner you are trying, use Eval or Run instead.
 
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

Back
Top Bottom