0

Simple question, but I am new to databases. I have a field called 'ActorRetired?', and in some VBA code I need to set the value of it to -1. But When I try:

Me.ActorRetired?.Value = -1

I get the error 'Compile Error: Expected: Expression' with the question mark highlighted.

How do I refer to the field name without this error? So far I have tried

Me.[ActorRetired?].Value = -1
Me."ActorRetired?".Value = -1

But neither has worked. Please help!

4
  • Try Me.ActorRetired_.value. But I'd recommend you to rename your control/column to some name which does not contain problematic chars, for example, to DoesActionRetired. – Akina Oct 6 '20 at 8:30
  • @Akina Doing that gives me 'Method or data member not found' and there's a lot of things I would have to change if I changed the field name, but if there's no other solution there I will. – Timothy Cahill Oct 6 '20 at 8:44
  • In VBA (form module) type Me. - intellisense will suggest all possible variants, look in the list for your column name as it is interpreted by VBA. When I create a table with the column named ActorRetired?, then create a form with this table as a rowsource using master, and then try to refer to the column's value in Form_Current - shown expression works correctly. So describe detailed what do you do... – Akina Oct 6 '20 at 8:48
  • You might need to use Me![ActorRetired?] = -1 - it's been a good long while since I used Access, but I remember something along those lines for fields that aren't directly added as an object to the form. – Hannah Vernon Oct 7 '20 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.