Syntax error

  • Thread starter Thread starter ladybug via AccessMonster.com
  • Start date Start date
L

ladybug via AccessMonster.com

I received a syntax error with this code:

Private Sub Function_AfterUpdate()
On Error Resume Next
Task.RowSource = "Select Function.Task " & _
"FROM Function " & _
"WHERE Function.Function = '" & Function.Value & "' " & _
"ORDER BY Function.Task;"
End Sub

Can anyone help me figure out what is wrong?
 
What is function?
Since it is an Access reserved work, I would use an different name.
What is Function.Task?
 
Function is a reserved word.

If you cannot (or will not) change the name of the table, at least enclose
it in square brackets. You should also use the Me keyword to help Access
know that Task and Function are the names of controls on your form.

Me!Task.RowSource = "Select [Function].Task " & _
"FROM [Function] " & _
"WHERE [Function].[Function] = '" & Me![Function] & "' " & _
"ORDER BY [Function].Task;"

For a comprehensive discussion of the problem with reserved words, see what
Allen Browne has at http://www.allenbrowne.com/AppIssueBadWord.html
 
I have a table named Function. Within that table there are three fields:
Autonumber, Function, Task.
I would like once Function is selected only the appropriate Tasks appear.
What is function?
Since it is an Access reserved work, I would use an different name.
What is Function.Task?
I received a syntax error with this code:
[quoted text clipped - 7 lines]
Can anyone help me figure out what is wrong?
 
THANK YOU!!!! I understand now why I was getting that error. It could not
tell between the table and the field. I tried to go back and change the
table name, but it would not let me. Your way works though too! I will make
sure my naming conventions are better in the future.
Thank you again. Have a wonderful evening!
Douglas said:
Function is a reserved word.

If you cannot (or will not) change the name of the table, at least enclose
it in square brackets. You should also use the Me keyword to help Access
know that Task and Function are the names of controls on your form.

Me!Task.RowSource = "Select [Function].Task " & _
"FROM [Function] " & _
"WHERE [Function].[Function] = '" & Me![Function] & "' " & _
"ORDER BY [Function].Task;"

For a comprehensive discussion of the problem with reserved words, see what
Allen Browne has at http://www.allenbrowne.com/AppIssueBadWord.html
I received a syntax error with this code:
[quoted text clipped - 7 lines]
Can anyone help me figure out what is wrong?
 
Back
Top