?
Solved

AfterUpdate event error Urgent 500 points

Posted on 2005-02-28
5
Medium Priority
?
207 Views
Last Modified: 2008-03-06
have a combo box on a form the has an afterupdate event that populates an other combo box on a subform

The after update is below

I have ran the select statement in a querry and it works when i manualy enter the number.

The error i get syntax error (missing Operator) in querry expression 'tblCost.PersonnelID Where (tblCost.PersonnelID)= 1'.

Me!fsubTimeEntry!cboCostRateId.RowSource = "SELECT tblRateTypes.RateDescription, Max(tblCost.CostId) AS CostId, tblCost.RateID, Max(tblCost.Rev) AS MaxOfRev, Max(tblCost.Rate) AS MaxOfRate, tblCost.PersonnelID FROM ((tblCost LEFT JOIN tblEmpTerm ON tblCost.EmpTermID = tblEmpTerm.EmpTermID) LEFT JOIN tblPersonnel ON tblCost.PersonnelID = tblPersonnel.PersID) LEFT JOIN tblRateTypes ON tblCost.RateID = tblRateTypes.RateId GROUP BY tblRateTypes.RateDescription, tblCost.RateID, tblCost.PersonnelID WHERE(tblCost.PersonnelID) = " & Me.cboPersonnelID

So the querry works but i cant get it to work with the form and subform
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 13420382
Hi ellandrd,
In the code you posted there is no space after WHERE.  If that's the case in your real query then add one.

Pete
0
 
LVL 16

Author Comment

by:ellandrd
ID: 13420411
put the space in still the same error
0
 
LVL 19

Accepted Solution

by:
david251 earned 2000 total points
ID: 13420416
Try changing it to:

Me!fsubTimeEntry!cboCostRateId.RowSource = "SELECT tblRateTypes.RateDescription, Max(tblCost.CostId) AS CostId, tblCost.RateID, Max(tblCost.Rev) AS MaxOfRev, Max(tblCost.Rate) AS MaxOfRate, tblCost.PersonnelID FROM ((tblCost LEFT JOIN tblEmpTerm ON tblCost.EmpTermID = tblEmpTerm.EmpTermID) LEFT JOIN tblPersonnel ON tblCost.PersonnelID = tblPersonnel.PersID) LEFT JOIN tblRateTypes ON tblCost.RateID = tblRateTypes.RateId WHERE(tblCost.PersonnelID) = " & Me.cboPersonnelID & " GROUP BY tblRateTypes.RateDescription, tblCost.RateID, tblCost.PersonnelID "

-David251
0
 
LVL 16

Author Comment

by:ellandrd
ID: 13420446
Awsome thank you but i havnt seen that before where the WHERE has to move.

Any reason why?
0
 
LVL 19

Expert Comment

by:david251
ID: 13420475
Glad I could help,

To answer your question, here is the format for sql statments. If it is not in this order you will get an error

Select
From
   Join
    on
Where
Group by
Having

Thanks for the points/grade.

-David251
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question