1

In the following example where POOPTrst is a a DAO recordset (systems object) referencing the Vb SQL query or statement.  this code returns "Run-time error 2482" and/or "Microsoft Access cannot find the name 'POOPTrst' you entered in the expression"  (note:  the POOPTVal variable holds a date).

POOPTWkDmd = Eval("POOPTrst" & "!" & POOPTVal)

In the following example where POOPTrst is a a DAO recordset referencing the Vb SQL query.  this code returns "Run-time error 3256" and/or "Item not found in this collection"  (note: with or without parenthesis around the variable POOPTVal)

POOPTWkDmd(POOPTCounterInt) = POOPTrst!Eval(POOPTVal)

If I remove the Eval function and the POOPT date variable and type literal characters into the code I get the proper/expected return value and/or response (note:  the problem is that 1/5/2009 is a dynamic value that is calculated at run time

POOPTWkDmd(POOPTCounterInt) = POOPTrst![1/5/2009]   
4
  • Exactly what is the IDE you are using to write the code? Commented Jan 23, 2016 at 21:43
  • ??? MS Access Vb Module Environment Commented Jan 23, 2016 at 21:47
  • Then it is not MySql and it is not VB.NET. The tags include descriptions and instructions when to use and when not too Commented Jan 23, 2016 at 21:47
  • My error... I'm new to stackoverflow and I think these were the default tags Commented Jan 23, 2016 at 21:50

2 Answers 2

2

Use this syntax: rs("Fieldname") instead of rs!Fieldname

POOPTVal = "1/5/2009"
POOPTWkDmd = POOPTrst(POOPTVal)

for more explanation see this answer: https://stackoverflow.com/a/34969410/3820271

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

Comments

2

One issue is that Eval() doesn't know anything about VBA variables or objects such as recordsets. If you want to use those, build a string containing their values and give Eval() that string.

However, I'm not sure Eval() is what you should use here. It seems you want to reference the value of a field in your POOPTrst recordset, with a variable to hold that field name. If that is correct, use the variable with the recordset's Fields collection: POOPTrst.Fields(POOPTVal).Value

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.