Use a variable for a field name in ACCESS 2010 vba procedure

This is more of can it be done than anything else.  I have a form and all the text fields are the underlying name of the column in thetable with the txt prefix.   So, I want to loop through all the text fields, get rid of the txt and use the result as the name of the field,  It pulls the correct information, but when it gets to the actual field name, no matter what I do, it will not recogznie the strField.  I know it is creating the correct name of the field (debug prints!), but the value is not being used as the field name in the loop.  I have tried quotes, but that did not work either.  Or can this even be done?

Private Sub SaveData()
On Error GoTo ErrorHandler
Dim rst As DAO.Recordset
Dim ctl As Control
Dim strField As String
Dim strValue As String
Set rst = CurrentDb.OpenRecordset("tblCustomers", dbOpenTable)
With rst
    .AddNew

For Each ctl In Me.Controls
    If Left(ctl.Name, 3) = "txt" Then
        Debug.Print "Control Name: " & ctl.Name   -THIS WORKS
        strField = Mid(ctl.Name, 4, 25)
        Debug.Print "FieldName: " & strField  -THIS WORKS
        strValue = ctl
        Debug.Print "Value: " & strValue   -THIS WORKS
        ![& strField & ] = strValue  DOES NOT RECOGNIZE FIELD NAME
    End If
 Next ctl
   
    .Update
End With
rst.Close
Set rst = Nothing

Exit_ErrorHandler:
    Exit Sub
ErrorHandler:
    MsgBox "Error Number: " & Err.Number & " Description: " & Err.Description
    Resume Exit_ErrorHandler
End Sub
Sandra SmithRetiredAsked:
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.

Ryan ChongCommented:
try

![""""&strField &"""" ] = strValue
0
Rgonzo1971Commented:
Hi,

pls try
instead of
![& strField & ] = strValue  DOES NOT RECOGNIZE FIELD NAME
this
.Fields(strField) = strValue  

Regards
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
Sandra SmithRetiredAuthor Commented:
That works.  Anything with quotes just errored out.  This saves me a LOT of typing!  Thank you.
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
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.