Problem with Criteria in Code

mamandeno

Dabbler in Access
Local time
Tomorrow, 10:14
Joined
Jan 8, 2007
Messages
30
Hi,

Can anyone see what the syntax error in filter criteria in this code is?

Code:
If CurrentProject.AllForms("TrainingRecs").IsLoaded Then
Me.Filter = "Total Name =" & "'" & Forms![TrainingRecs]![TotalName] & "'"


ElseIf CurrentProject.AllForms("ReportTrainee").IsLoaded Then
Me.Filter = "Total Name =" & "'" & Forms![ReportTrainee]![TotalName] & "'"
Else: End If

I really struggle to get my head round the 's "s and &s and I can't see for looking what is wrong with the code, but I am getting a syntax error message every time it runs.

I have tried moving the ' to immediately after Total Name = but I get the same error.

This is the only bug left in the new database I have made, which is due for presentation to my boss in 1.5 working days.

Argggggh!

Can someone help me?

Thanks in anticipation, Mike.
 
Put square brackets around the field name
"Total Name ="
to
"[Total Name]="

Now you see why it is best to NOT put spaces in object names as you have to remember to do special things that you would not have to do if you didn't have embedded spaces.
 

Users who are viewing this thread

Back
Top Bottom