Variable Field name

I am using a dao record set and updating an Access table.  I have field names for the months for this year and last year.  (ex  PJAN,TJAN,PFEB,TFEB).  I look at a date and know that 01 is January, 02 is February etc  and store PJAN or what ever field it should be in a strin variable...strPmonth and strTmonth.  When I update the record set I want to say rsInvhd!strPmonth.  What is the syntax?  I've fought through all the hard stuff and get to something simple and just can't figure it out.  I put the point value high because I need to know
tnegAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rovermCommented:
Don't use ! but the Fields property: rsInvhd.Fields(strValue).Value = ... and so on!
Good Luck !

grtx, Mark
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TigerZhaoCommented:
what's mean?
can you write some code even if it's not work
0
James_stillmanCommented:
Hey Tneg I haven't done that much DB programming but I have used the ! operator before and when I used it the syntax was as follows.


    With recordsetName
          .MoveFirst 'Or the record u wish to update
           !strPmonth=NewValue
           .Update
    end with  

So as far as I know for straight forward use it is used exactly like a variable.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

rovermCommented:
assuming:
rs = filled recordset and minimal keyset cursor,
strMonth = month to update
strValue = update value

rs.Field(strMonth).Value = strValue
rs.Update

The Field prop offers some nice features, you can also check if the value isn't changed somewhere else by another user.
 
0
tnegAuthor Commented:
Great!  I'm almost there now

0
rovermCommented:
I used this prop in a DBGrid, if you like I to know why, how and what, let me know !

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.