Page 3 of 5 FirstFirst 12345 LastLast
Results 31 to 45 of 68
  1. #31
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by Lou_Reed View Post
    I am very concerned about the last issue. I must say in my defense that I inherited this db and all the macro that came with it including mcrRestore. I am creating this in a non-profit seeking organization. It will never be sold.

    In order to get right with the copyrighted code what must I do? Is it a question of simple copyright and all I need to do is replace the removed copyright?

    I can do that. I just do not want to be in copyright violation.
    Yes, it is that simple. Go to the access.mvps.org site, copy and paste the lines at the top of the function into the function in your code......



    Please note that the comment was in no way directed at you.
    You have stated several times before that you had inherited the dB; I was just letting you know what I found.

  2. #32
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I know that I have mentioned this before, but you have code that has "Form_" as a prefix. That is the way Access uses to know what the object is - you should never use that nomenclature.
    Code:
    Private Sub Form_Close()  '<<-- Good - Required by Access
        Form_frmProjectManagement.Requery   '<<---BAD. You should never reference a form this way!!
    End Sub
    You have approximately 31 references in the code like this. These need to be fixed!!!

    You have the button code in the form "sfrmTelework1" that is trying to requery two sub forms by using this code
    Code:
    Private Sub btnClose_Click()
        Dim response
    
        If (DCount("*", "tblTelework", "[PersonnelID] = [Forms]![frmPersonnel].[PersonnelID] AND [isActive] = true")) > 0 Then
    
            response = MsgBox("Are you sure close Telework Contract?", vbYesNo, "Close ", 0, 0)
    
            If response = 6 Then
                Me.EndDate = Date
                Me.isActive = No
                Form_sfrmTelework1.Requery
                Form_sfrmTelework.Requery
                updateButtons
            End If
        End If
    End Sub
    I'm not saying this is the cause of the current error, but it will go a long way to fixing a lot of errors...

  3. #33
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    These are translated macros to BA code. I did not put the form_ in there. Bill Gates did. I just took the translated code as gospel and there you are.

    I can change Form_. I just am not sure why the Macro to VBA translator used it when I and anyone else knows that is wrong.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  4. #34
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Many of the wizards create antiquated code; this is an example of that. Frankly, many of the MS sample databases use poor design practices, like spaces in names. Use both as bumps in the right direction, not as-is solutions.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #35
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In the last week I converted the macros to VBA code. So these 31 instances must be in that code. I removed all other instances of Form_ last month before i
    translated the macros to VBA code.

    Still 31 instances sounds like a lot when you consider the small amount of code.
    Anyway thanks for the heads up.

    I will check it.

    Respectfully,

    Lou Reed

  6. #36
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    The attached zip fie contains the db that is the one I am working on. There is an inconsistency. I find no other instances of Form_ being used. You said there were 29 others. I do not find them. There are other instances of Form_, but these should not be converted

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  7. #37
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I have made a serious error. In the previous post, I uploaded the wrong file. The one in this post is the correct one.

    Please use this one.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  8. #38
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    After the change of Form_ to Forms! All that happens is that it crashes on the next line.

    updateButtons.

    That term is used in many places about 7 in all with no complaints from the compiler.

    What am I doing wrong?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  9. #39
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I thought you had resolved the "Forms_" issue a while ago.....


    After the change of Form_ to Forms! All that happens is that it crashes on the next line.

    updateButtons.
    In an earlier version of the dB, the form "sfrmTelework1" had a sub, "Public Sub updateButtons()", that is now missing from the form module.

    Try adding this code back to the form "sfrmTelework1" code module:
    Code:
    Public Sub updateButtons()
        If DCount("*", "tblTelework", "[PersonnelID] = [Forms]![frmPersonnel].[PersonnelID] AND [isActive] = true") = 0 Then
            Me.btnClose.Enabled = False
            Me.btnEditTelework.Enabled = False
            Me.btnNew.Enabled = True
        Else
            Me.btnClose.Enabled = True
            Me.btnEditTelework.Enabled = True
            Me.btnNew.Enabled = False
        End If
    End Sub

  10. #40
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I will add the VBA code and thanks for your help.

    Respectfully,

    Lou Reed

  11. #41
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Yes, that works. Sorry for my stupidity. The updateButtons SUb was clearly shown in the sfrm.PropertyPass1.Requery

    The update button Sub was clearly there. All I had to do was to copy it and paste in the code where it was needed: .
    the Sub for sfrmTelework etc.

    My questions since it got there in one sub code and not another is this not an error in the macro to VBA code translator?

    I could have clumsily eliminated it in the SUB where it was missing, but I do not think that I did.

    I assume that it is put there by the macro to VBA translator that is in MS Access 2010.

    So why did it go in one sub and not another.

    Strange.

    Also, when I went to compile the compile line was at times greyed out and I could not compile. How can I ungrey it out and use it. It is of no use to me
    in the greyed form?

    Any help appreciated. Thanks in advance.


    Respectfully,


    Lou Reed

  12. #42
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If the compile option is greyed out, the project must already be compiled. Make and save any code change to enable it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #43
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Quote Originally Posted by JoeM View Post
    Ah, OK. I think I see what you want to do know. You want to run the VBA code you come up with from a Macro.
    You can do that. Just keep the first line of the converted VBA code starting with "Function...". I would recommend changing the name so that it is named different from the original Macro name.
    For this example, let's that the name (first line) of our converted code now looks like this:
    Code:
    Function MyCode()
    Then, in a new Macro, select the RunCode action, and enter the name of your VBA code, like this: MyCode()

    Now, when you click the Macro, it will run that code.

    Could you give n example?

    I understand what you said but I am afraid I willl mess uo the syntax.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  14. #44
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In this method that you talk about why not just call the Function. Use something like

    Call MyCode()

    It just seems more direct. Also, where is the source for Function MyCode()? In the navigation pane?

    Also, why give it a different name from the macro name?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  15. #45
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I really need an answer to this questions. I am doing what I was told to on this forum,. but I think my option of just calling the function instead of running a macro that runs the code is a good idea. Also, my two questions about that need to be answered.

    Any help appreciated. thanks in advance.

    Respectfully,

    Lou Reed

Page 3 of 5 FirstFirst 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Converting Macros To VBA in 2013 Office
    By data808 in forum Access
    Replies: 8
    Last Post: 06-17-2014, 02:37 AM
  2. Wizard - Create code Code vs. Macros?
    By runbear in forum Forms
    Replies: 3
    Last Post: 01-08-2014, 12:52 PM
  3. VBA code for macros
    By marcvanderpeet12 in forum Access
    Replies: 1
    Last Post: 10-31-2013, 06:24 AM
  4. Converting SQL to VBA code
    By Davidyam in forum Access
    Replies: 3
    Last Post: 04-18-2012, 10:29 AM
  5. Replies: 9
    Last Post: 01-11-2012, 01:29 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