1

I'm sure this is pretty simple but I'm still in the early phases of learning how to use VBA in access. I'm not sure what I've messed up on but this is what happened:

I have a form with a combination of lists and combo boxes. I've made a command that returns an SQL query, in its original table form, when a double click is made on a list. When I originally wrote the code it only had 2 fields, a number and a dollar figure. The code:

Private Sub List43_DblClick(Cancel As Integer)

DoCmd.Query ("BuyerPerfDetailPA2")

End Sub

Worked when there where 2 fields, but i have recently added a third, a Yes/No response in column 3. Now, when I run this code, I receive a "compile error" listed in the title. My guess is the added column it cannot match - as the Query has a WHERE clause (WHERE (((CombineTables.[PA#])=Forms![Buyer Performance Report]!List43). The PA# is assigned to the first column on the list (dollar amount is 2, and yes/no is 3) 3.

After the error, when I press OK it does appear however that the query has ran, so it may also be just a problem access is having with VBA.

Any suggestions? I hope this wasn't too murky.

1 Answer 1

1

"Method or data member not found" is a compile error which occurs because DoCmd has no method named Query.

If you want to open BuyerPerfDetailPA2 in Datasheet View, use this ...

DoCmd.OpenQuery "BuyerPerfDetailPA2"

You don't need parentheses there.

If BuyerPerfDetailPA2 is actually an "action query", and you want to execute it, use ...

CurrentDb.Execute "BuyerPerfDetailPA2", dbFailOnError

If neither of those suggestions is what you want, tell us what you want in more detail and show us the SQL for BuyerPerfDetailPA2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.