Share via

Access VBA - Autocorrect changing code

Anonymous
2013-08-30T16:07:54+00:00

I thought I was going crazy but after testing it today I noticed that the Access VBA autocorrect seems to be changing my code.

I've found that when I put a function such as Date() in code with multiple lines and then move to a new line, some funky autocorrect changes my Date() to Date and moves and occasionally drops the last line of the remaining code.

Is there a way to prevent this from happening? I've had several lines of code that didn't work correctly after the autocorrect changed it.

Example:

    strSQL = "INSERT INTO tblCalls ( StuID, CallType, DateAdded, [USER], Comments ) " & _

                        "SELECT  StuID, CallType, '" & Date() & "' , [School], " & _

                        "'Start: " & Format(datStart, "MM/DD/YYYY") & "' " & _

             "FROM [tblPendTemp] WHERE ImportStatus IS NULL "

is changed automatically to

    strSQL = "INSERT INTO tblCalls ( StuID, CallType, DateAdded, [USER], Comments ) " & _

                        "SELECT  StuID, CallType, '" & Date & "' , [School], " & "'Start: " & _

                        Format(datStart, "MM/DD/YYYY") & "' " & "FROM [tblPendTemp] WHERE ImportStatus IS NULL " _

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

12 answers

Sort by: Most helpful
  1. ScottGem 68,830 Reputation points Volunteer Moderator
    2015-11-18T12:36:14+00:00

    If I were coding it I would have do it a bit differently to make for ease of debugging. I would use:

    Dim strSQL As String

    strSQL = "SQL statement"

    CurrentDB.Execute strSQL

    I have been participating on these types of Q&A boards since the days of Compuserve. While the way the boards work has gotten better. the tone of them has changed little. Referring to thick skin was not the best choice of words, though it applies. But there are a few facts that anyone approaching these boards needs to understand:

    1. What I said before about written communication. Its often hard to tell the attitude of a person just on the written word
    2. People come here to help. If someone posts a response there is a 99% chance that response was meant to be helpful. If it was worded badly or the responder was in a hurry etc. it may appear offputting. But if one understands that most of the people here are volunteers, donating their time and expertise to help, then it stands to reason they are not going to respond to a question unless it provides help. If the poster understands that they may not feel as put off by the answers.
    3. Anonymity. Responders don't know the poster and vice versa. Posters will probably never encounter the responder except through the forum. Many people use handles that further protect their identity. So why get upset by something someone says that doesn't know you at all?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-11-18T04:29:21+00:00

    Good news is that after re-linking the 3rd party references and fixing all compilation issues even if not directly related to the problem the error seems to have stopped.

    I am certain it was me that wrote this, but I honestly do not remember doing it or why I coded it this way.  I vaguely remember something about a gridview or listbox and needing a select but I may have things mixed up.  It has been working forever so it has not warranted any attention.

    I do like this better though seems as though it would help when debugging because its not all stuffed into "" 

    It may not be your intention to dissuade people from participating, but the culture in these forums can really be harsh at times and it seems to go unchecked by peers or even moderators.  I have noticed that it is not limited to Microsoft forums and in fact is worse elsewhere.

    Should it be a requirement for people who look to this forum to have a thick skin?  That seems counter intuitive to have any barrier to entry or expected threshold for stress.  I would think that Microsoft would want to tap into as many of the aspiring developers rather than to create a club of an elite few.  I think we would all be better served if we could keep a positive attitude and come from a basis of affirmation.

    Was this answer helpful?

    0 comments No comments