Access error 3125 when setting .ControlSource

I swear I hate Access sometimes!

OK, so here is my VBA code attached to a command button.  The point of the button is obviously to toggle the source of a specific field:

    If Me.txtNum.ControlSource = "=[TemplateSequence] & ""."" & [LineItemNumber]" Then
        Me.txtNum.ControlSource = "LineItemNumber"
        Me.cmdRenumber.Caption = "Auto Renumber"
    Else
        Me.txtNum.ControlSource = "=[TemplateSequence] & ""."" & [LineItemNumber]"
        Me.cmdRenumber.Caption = "Manual Renumber"
    End If

This works just fine unless a user presses the command button repeatedly.  After a few times, Access throws this error message on the command "Me.txtNum.ControlSource = ...".  Does not matter which IF condition is being processed -- sometimes happens on the true condition and sometimes on the ELSE condition.

Here is the error -- it makes no sense to me:

error number 3125, "'select * from....(this appears to be the recordsource of the form)' is not a valid name.  Make sure that it does not include invalid characters or punctuation and that it is not too long."


I can't make rhyme or reason here.  Works just fine, then suddenly pops up what seems to be a bogus error.

Anybody have ideas here?


P.S.  I know somebody is going to say rebuild the form.  That would take hours and hours because this is a *very* complex form with lots of tabs, subforms, and form automation.
LVL 14
mds-cosAsked:
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.

gemartiCommented:
It wouldn't be encountering an EOF or BOF would it??


0
gemartiCommented:
Are there any leading spaces in the column Me.txtNum.ControlSource ?
0
tbsgadiCommented:
Try if  Me.cmdRenumber.Caption = "Auto Renumber" Then...

Gary
0
mds-cosAuthor Commented:
No .EOF or .BOF (the code I posted is the whole thing, not looping through records here -- just automating the form).  No leading spaces...again the code shows the only two possible values.  And problem is not with the conditional check (I get the same error in another spot where I am simply setting the control source to "default" value without an if...then construct around it).

But........

Further info....the whole form just blew up.  I mean totally blew up....will not open in design mode, will not import to a new database, and can't even save it as text in the immediate window to try to rebuild.

So.....my bogus error appears to be warning signs of corrupt form rather than a specific code issue.  I was kind of worried about that when I originally posted this question, but shutting eyes tight against the idea.

Right now I'm rebuilding to a clean database from previous development version of the app.  Once that is done I'll see if my error on the above code still shows up.
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
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 Legacy OS

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.