Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    What is causing this to change the varaiable letters rom Caps to small

    In frmEmail there is some VBA code behind the command to send an employee an email.
    It is the line:

    strWho = txtemailaddress

    Now when I put this loine of code in originally it was:

    strWho = txtEmailAddress

    Upon saving the file it switch to the first line. Either one works. But why does it change it?

    I know that somewhere a line must define it as txtemailadrress.

    I have had this issue before. But then t least I could find when the variable was originally defined.



    I am not sure why it is doing this.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

    PS The attached files show the issue that I am talking about.
    Attached Files Attached Files
    Last edited by Lou_Reed; 06-22-2017 at 01:17 PM. Reason: correction

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I have encountered this and usually give up finding cause and just ignore.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I know that somewhere a line must define it as txtemailadrress
    Or perhaps you have a control or field named txtemailadrress?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The single 'd' and double 'r' are typos in the post. I searched for field or control named txtemailaddress (with lower case letters) and can't find. As I said, I've also experienced this and just ignore.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Your Access VBA project is getting a little confused.

    Hold down the shift key and open the dB.
    Open "frmEmail" in design view.
    Click on the control "txtEmailAddress".
    Change the control name FROM "txtEmailAddress" TO "txtEmailAddress1". (Notice the 1 at the end) (you can use any character..... )
    Close the form (save - yes).
    In the menu bar select "Database Tools/Compact & Repair" while holding down the shift key.

    Open the IDE by pressing ctl-G, then ctl-R. Open the module for frmEmail.
    Scroll down to the line "strWho = txtEmailAddress"
    Add a 1 (or the characters(s) you used) to the end of "txtemailaddress". (BTW, IMO, it would be better if you used "ME.txtemailaddress" in code)
    Move down one line using the arrow key.

    The control name should now be in the same case as on the form.

    The form should now be open in design view.
    Remove the 1 (or the characters(s) you used) from the control name, then save and close the form.


    You should make sure *EVERY* code module (form/report modules and standard modules) has these two lines at the top:
    Code:
    Option Compare Database
    Option Explicit
    Fix the errors in your code.....



    In the future:
    Start compiling your code after every few lines added, changed or deleted.
    Same goes for "Compact & Repair" when changing forms/reports.

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by ssanfu View Post
    Your Access VBA project is getting a little confused.

    Hold down the shift key and open the dB.
    Open "frmEmail" in design view.
    Click on the control "txtEmailAddress".
    Change the control name FROM "txtEmailAddress" TO "txtEmailAddress1". (Notice the 1 at the end) (you can use any character..... )
    Close the form (save - yes).
    In the menu bar select "Database Tools/Compact & Repair" while holding down the shift key.

    Open the IDE by pressing ctl-G, then ctl-R. Open the module for frmEmail.
    Scroll down to the line "strWho = txtEmailAddress"
    Add a 1 (or the characters(s) you used) to the end of "txtemailaddress". (BTW, IMO, it would be better if you used "ME.txtemailaddress" in code)
    Move down one line using the arrow key.

    The control name should now be in the same case as on the form.

    The form should now be open in design view.
    Remove the 1 (or the characters(s) you used) from the control name, then save and close the form.


    You should make sure *EVERY* code module (form/report modules and standard modules) has these two lines at the top:
    Code:
    Option Compare Database
    Option Explicit
    Fix the errors in your code.....



    In the future:
    Start compiling your code after every few lines added, changed or deleted.
    Same goes for "Compact & Repair" when changing forms/reports.
    I am not sure what these steps are meant to accomplish.

    In the line when you say

    Scroll down to the line "strWho =txtEamilAddress"

    Actually you cannot do this. The line is really when the IDE is opened is "strWho = txtaamiladdress" . The E and A are small, because as I stated in above post the code here changes strWho =txtEamilAddress to "txetmailaddress"
    when it s saved. It is only has the capital E and A before it is saved. Any other action (which is usually to save) causes the E and A to become e and a. Small versions, not capital versions.

    At the end of your procedure I have "strWho = txtaamiladdress1" in the VBA code.

    So again I an unsure what this is accomplishing.

    Also, I do compile the VBAS after every line. I know because when I put in a syntax error is complains.
    I changed the control txtemailaddress to xtemailaddress1.

    That is all that I did.

    Why should I use Me.txtemailaddress in the VBA code?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Last edited by Lou_Reed; 06-26-2017 at 11:21 AM. Reason: correction

  7. #7
    SirParadox is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2017
    Posts
    2
    This also happens in VB6. Two different forums. Each have a 'dim myString as string'
    Open one. change myString to mystring. It will love to globally replace that on all other forms. Even if they are totally in different scopes. I can't tell you how many times it changed 'dim rc as long' to 'dim RC as long' and back.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    Also, I do compile the VBAS after every line. I know because when I put in a syntax error is complains.
    a syntax error is not the same as a compile error which again is not the same as a runtime error.

    Syntax errors happen when you do not use the correct syntax and are reported as you complete a line- typically missing a double quote in a line or not completing a phrase such as

    if x=y

    (then is missing)

    compile errors occur when you compile the code (i.e. when you select debug>compile) and might be because you have spelt a property incorrectly. If you don't use debug>compile then the code is compiled as you execute it, meaning it doesn't find the error until the app is running and gets mixed in with runtime errors.

    runtime errors occur when you run the code such as divide by zero or trying to base code routing on a null value

    So I believe you are mistaking syntax errors for compile errors. They are different

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Lou,
    You wrote
    Quote Originally Posted by Lou_Reed View Post
    In frmEmail there is some VBA code behind the command to send an employee an email.
    It is the line:

    strWho = txtemailaddress

    Now when I put this loine of code in originally it was:

    strWho = txtEmailAddress

    Upon saving the file it switch to the first line. Either one works. But why does it change it?
    I said that Access was getting confused. You could also say that there is minor corruption in the VBA project.
    You wanted to know how to correct it. I downloaded your db in Post #1, performed the steps in Post #5 and "txtemailaddress" is now "txtEmailAddress".
    Did you try the steps? Make a back up copy and try following the steps..



    Quote Originally Posted by Lou_Reed View Post
    Why should I use Me.txtemailaddress in the VBA code?
    "Me." is shorthand for "Forms!FormName". It helps disambiguate the object.

    For instance, you have a field named "Customer". If you drag a field name to the form, Access will name the control with the same as the field.
    So now you have a field named "Customer", a control named "Customer" and possibly a table named "Customer".
    If you then have code that references "Customer", what object are you referring to???

    If Access uses the field instead of the control, any control event will not fire.
    And when you have 100 lines in a sub/function and there is a line like "strWho =txtEamilAddress", what is "strWho" and "txtEamilAddress" referring to? A variable in code or an object on a form or a field in the form??
    Remember, even though a field is in the form record source, it doesn't need to be bound to a control to be able to reference the field.

    "strWho = Me.txtEamilAddress" is just a lot easier to undrestand.


    I use prefixes "tbl" for tables, "frm" and "sf" (sub form) for forms, "qry" for queries and "rpt" for reports.
    That way I never have two objects with the same name.

  10. #10
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I did try your steps. They worked, I just think it would be easier to just give txtEmailAddress the new name txtEmailAddress1 and be done with it. When I use txtEmailAddress and save the code the field
    is saved as txtemailaddress. This is obviously not what I want at all, I want txtEmailAddress. I cannot get that. MS access thinks it knows best and changes it to txtemailaddress.

    There is nothing in the VBA code that defined txtemailaddress anywhere.

    If you can find it please show me. I would assume it would be on the VBA code page, but it is not. The use of Vtools software and its superior search capability does not work either. The software can find all instances of txtemailaddress and point each of them out in context. But after the search there is no place in the db that defines txtemailaddress. There just is not.

    Yet, when I save the code with txtEmailAddress, it saves it as txtemailaddress. Period.

    Please put in more elaborate steps to your procedure. Maybe, I missed something in your steps.

    I will your advice and put the Me. in front of txtEmailAddress. Will solve the problem, maybe? I just do not think so. I will try all the same.

    Respectfully,

    Lou Reed

  11. #11
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am confused by something in your procedure thatyou outlined in a previous post in this thread.

    Code:
    Hold down the shift key and open the dB.
    Open "frmEmail" in design view.
    Click on the control "txtEmailAddress".
    Change the control name FROM "txtEmailAddress" TO "txtEmailAddress1". (Notice the 1 at the end) (you can use any character.....:rolleyes: )
    Close the form (save - yes).
    In the menu bar select "Database Tools/Compact & Repair" while holding down the shift key. 
    
    Open the IDE by pressing ctl-G, then ctl-R. Open the module for frmEmail.
    Scroll down to the line "strWho = txtEmailAddress"
    Add a 1 (or the characters(s) you used) to the end of "txtemailaddress". (BTW, IMO, it would be better if you used "ME.txtemailaddress" in code)
    Move down one line using the arrow key.
    
    The control name should now be in the same case as on the form.
    
    The form should now be open in design view.
    Remove the 1 (or the characters(s) you used) from the control name, then save and close the form.
    


    Here you said to add 1 or whatever, you used in the txtemailaddress in the textbox. Then move down one 1 line.

    The control name should now be the same as on the form. It is.

    Then you say the form should be open in design view.
    Then remove 1 (or whatever character you used) from the control name.

    But you never say what to do aout the line whcih at this point is

    strWho = txtEmailAddress1 (at least in my case).

    That line should have the 1 removed also, but you never say where.

    I am not sure what to do in that case I know the line

    strWho = txtEmailAddress1

    must be changed to

    strWho = txtEmailAddress
    .

    But where? The part where i add a 1 to the end of txtEmailaddress in the VBA code and
    then move by arrow to the next line must be to save the previous VBA code line.

    But when is the 1 removed?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed




  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Lou_Reed View Post
    I did try your steps. They worked, I just think it would be easier to just give txtEmailAddress the new name txtEmailAddress1 and be done with it. You can do that. When I use txtEmailAddress and save the code the field is saved as txtemailaddress. This is obviously not what I want at all, I want txtEmailAddress. I cannot get that. Yes, you can. I showed you how. MS access thinks it knows best and changes it to txtemailaddress. It is not MS Access, it is a problem with the VBA project.

    There is nothing in the VBA code that defined txtemailaddress anywhere. Correct. You are referencing a control on a form. Hence the "Me." prefix so you understand that "txtemailaddress" is an object (control) on a form.

    If you can find it please show me. I would assume it would be on the VBA code page, but it is not. The use of Vtools software and its superior search capability does not work either. The software can find all instances of txtemailaddress and point each of them out in context. But after the search there is no place in the db that defines txtemailaddress. There just is not. Correct. See above

    Yet, when I save the code with txtEmailAddress, it saves it as txtemailaddress. Period. Yes...Because of the problem with the VBA project.

    Please put in more elaborate steps to your procedure. Maybe, I missed something in your steps.

    I will your advice and put the Me. in front of txtEmailAddress. Will solve the problem, maybe? I just do not think so. I will try all the same.


    Steps to change "txtemailaddress" (no caps) to "txtEmailAddress" (with caps)

    1) Hold down the shift key and open the dB. (Not really necessary. Can open the dB and close the form that opens.)

    The Form
    2) Open "frmEmail" in design view.
    3) Click on the control "txtEmailAddress". Open the properties sheet. Click on the OTHER tab.
    4) Change the control name FROM "txtEmailAddress" TO "txtEmailAddress1". (Notice the 1 at the end) (you can use any character..... )
    5) Close the form (save - yes).
    6) In the menu bar select "Database Tools/Compact & Repair" while holding down the shift key.

    The Code
    7) Open the IDE by pressing ctl-G, then ctl-R. Open the module for frmEmail.
    8) Scroll down to the line "strWho = txtEmailAddress" (at Line 72)
    9) Add a 1 (or the characters(s) you used when you renamed the control on the form) to the end of "txtemailaddress".
    (BTW, IMO, it would be better if you used "ME.txtemailaddress" in code)
    10) Move down one line using the arrow key.

    The control name in the code should now be in the same case as on the form.
    For example, the control name and the line in the VBA code should BOTH now be "txtEmailAddress1"
    When you edit the code, the form "frmEmail" will open in design view.

    11) Compile the code (in the menu, click on DEBUG/Compile)
    12) Save the VBA code

    The Form
    13) Close (and save) the form "frmEmail".
    14) In the menu, click on DATABASE TOOLS/Compact & Repair Database while holding down the shift key.
    15) Open "frmEmail" in design view (again).
    16) Click on the control "txtEmailAddress". Open the properties sheet. Click on the OTHER tab.
    17) Remove the 1 (or the characters(s) you used) from the control name ("txtEmailAddress1"), then close and save the form.
    18) Close the form (save - yes).
    19) In the menu bar select "Database Tools/Compact & Repair" while holding down the shift key.

    The Code
    20) In the IDE, scroll down to the line "strWho = txtEmailAddress1" (at Line 72 in the dB I have)
    21) Delete the character you added to the end of the name (in my case, I used a 1)
    The line should now be "strWho = txtEmailAddress" (I added the bold and color. The code will not show this formatting)
    22) Compile the code (in the menu, click on DEBUG/Compile)
    23) In the IDE, SAVE the code

    The Form
    24) Go back to the form "frmEmail" that is in design view. In the menu, click on DATABASE TOOLS/Compact & Repair Database
    25) Save the form "frmEmail" when/if asked.

    Done.......

  13. #13
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by June7 View Post
    I have encountered this and usually give up finding cause and just ignore.
    Do you know if Name Auto Correct was enabled?
    I tend to forget to turn it off in a new project, so I'm wondering if that's why I've never experienced this issue, since I suspect you make sure it's deselected.

  14. #14
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I turned off autocorrect on my db project a long time ago. I am painfully aware of the problems that can be caused when it is switched on. In my opinion it should permanently deleted or left out in the next version of MS Access.

    Respectfully,

    Lou Reed

  15. #15
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    in this section:
    The Code
    20) In the IDE, scroll down to the line "strWho = txtEmailAddress1" (at Line 72 in the dB I have)
    21) Delete the character you added to the end of the name (in my case, I used a 1)
    The line should now be "strWho = txtEmailAddress" (I added the bold and color. The code will not show this formatting)
    22) Compile the code (in the menu, click on DEBUG/Compile)
    23) In the IDE, SAVE the code
    [code]

    I compiled the code. Nothing much happened when I went back to try to compile the code again, it was greyed out so I must have compiled the first time.

    When you say save the VBA code

    I cannot save it with saving Division_Dashboard also. I know of no way to save the VBA code only.
    If there is a way tell me.

    Now I move on to the last section (section 4) and I am back in the IDE again.

    That is okay, I just minimized it when I left section 2. I did not close it.


    I do a lot of TOOLS/Compact & Repair Database why do it so ofte?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Change from DAO to ADO causing issues
    By PinkLady50 in forum Programming
    Replies: 17
    Last Post: 05-15-2017, 03:13 PM
  2. I want fill in boxes all Caps
    By MarkV in forum Access
    Replies: 3
    Last Post: 12-07-2014, 06:35 PM
  3. Replies: 2
    Last Post: 07-23-2014, 10:06 AM
  4. How to Set Font to Small Caps using VBA
    By EddieN1 in forum Access
    Replies: 3
    Last Post: 04-11-2014, 05:39 AM
  5. Replies: 5
    Last Post: 10-23-2012, 03:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums