Results 1 to 9 of 9
  1. #1
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61

    Database Not Responding

    So, I have built a little pricing tool (still tidying it up) and I have an issue. I have an unbound field box with some code in it. This code is to work out the part number of the finished item based on the selections in lists boxes.

    When the database is opened, it should load the one form I have, however it hangs.

    I know the code that makes it hang.
    Code:
    =IIf([lstFrequency] Is Null,"",IIf([lstCable] Is Null,"",IIf([lstArmour] Is Null,"",IIf([lstEndA] Is Null,"",IIf([lstEndB] Is Null,"",IIf([txtLength]=0,"","SL" & [Forms]![frmSilverLineCalculator]![lstArmour].[Column](1) & [Forms]![frmSilverLineCalculator]![lstFrequency].[Column](1) & [Forms]![frmSilverLineCalculator]![lstCable].[Column](1) & "-" & IIf([Forms]![frmSilverLineCalculator]![lstEndA].[Column](3)<[Forms]![frmSilverLineCalculator]![lstEndB].[Column](3),[Forms]![frmSilverLineCalculator]![lstEndA].[Column](1),[Forms]![frmSilverLineCalculator]![lstEndB].[Column](1)) & IIf([Forms]![frmSilverLineCalculator]![lstEndB].[Column](3)>[Forms]![frmSilverLineCalculator]![lstEndA].[Column](3),[Forms]![frmSilverLineCalculator]![lstEndB].[Column](1),[Forms]![frmSilverLineCalculator]![lstEndA].[Column](1)) & "-" & Format([Forms]![frmSilverLineCalculator]![txtLength],"00.00") & "M"))))))
    If I open the database with the shift key, edit the form, remove this code, the database works fine. If I then place this code back in the field box, works fine. Compact and Repair, works fine. Close and re-open, and now it hangs.

    Is there anyway I can shorten the code I have used?




    Please see attached >> Amphenol SilverLine Calculator.zip <<

    Also, this is not finished yet so no error handling on the VBA code yet.

    ~Matt

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The main syntax

    [lstFrequency] Is Null

    is valid in SQL but is not valid in Access VBA. The correct syntax here would be

    IsNull([lstFrequency])

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    If you have complex if statements, try making a function and let IT do the decisions.

  4. #4
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Code:
    Public Function strSilverLinePartNumber()
    On Error GoTo strSilverLinePartNumber_Err
    
        Dim strSilverLinePartNumberCable As String
            strSilverLinePartNumberCable = "SL" & DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstArmour]") & DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstCable]") & DLookup("[FrequencyCode]", "tblFrequencyList", "FrequencyID = [Forms]![frmSilverLineCalculator]![lstFrequency]")
        Dim strSilverLinePartNumberSeparator As String
            strSilverLinePartNumberSeparator = "-"
        Dim strSilverLinePartNumberConnectors As String
            If DLookup("[ComponentSequence]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndA]") < DLookup("[ComponentSequence]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndB]") Then
                strSilverLinePartNumberConnectors = DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndA]") & DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndB]")
            Else
                strSilverLinePartNumberConnectors = DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndB]") & DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndA]")
            End If
        Dim strSilverLinePartNumberLength
            strSilverLinePartNumberLength = (Format([Forms]![frmSilverLineCalculator]![txtLength], "00.00")) & "M"
    
        If (Eval("[Forms]![frmSilverLineCalculator]![lstFrequency] Is Null")) Then
                strSilverLinePartNumber = "Please Select Frequency"
        ElseIf (Eval("[Forms]![frmSilverLineCalculator]![lstCable] Is Null")) Then
                strSilverLinePartNumber = "Please Select Cable"
        ElseIf (Eval("[Forms]![frmSilverLineCalculator]![lstArmour] Is Null")) Then
                strSilverLinePartNumber = "Please Select Armour"
        ElseIf (Eval("[Forms]![frmSilverLineCalculator]![lstEndA] Is Null")) Then
                strSilverLinePartNumber = "Please Select End A"
        ElseIf (Eval("[Forms]![frmSilverLineCalculator]![lstEndB] Is Null")) Then
                strSilverLinePartNumber = "Please Select End B"
        ElseIf (Eval("[Forms]![frmSilverLineCalculator]![txtLength] = 0")) Then
                strSilverLinePartNumber = "Please Enter Length"
        Else
                strSilverLinePartNumber = strSilverLinePartNumberCable & strSilverLinePartNumberSeparator & strSilverLinePartNumberConnectors & strSilverLinePartNumberSeparator & strSilverLinePartNumberLength
        End If
        
    strSilverLinePartNumber_Exit:
        Exit Function
    
    strSilverLinePartNumber_Err:
        MsgBox Error$
        Resume strSilverLinePartNumber_Exit
        
    End Function
    I have the above code now, however when I reset the list boxes I now get an "Invalid Use of Null" message box. When all selections are made, the code works fine.

    Am wondering, do I need my Dim As Strings as part of the last If statement? IE, only work out the part number IF all selections made?

  5. #5
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Code:
        Dim strSilverLinePartNumberConnectors As String
            If DLookup("[ComponentSequence]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndA]") < DLookup("[ComponentSequence]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndB]") Then
                strSilverLinePartNumberConnectors = DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndA]") & DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndB]")
            Else
                strSilverLinePartNumberConnectors = DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndB]") & DLookup("[ComponentCode]", "tblComponentList", "ComponentID = [Forms]![frmSilverLineCalculator]![lstEndA]")
            End If
    Okay, so I tested each section and it is only the section above that gives the Null error....

  6. #6
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Update, nested the Dim As Strings in the final If statement and it works now. Will post the final code here once I have finished testing.

  7. #7
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Okay, so I have this working now. I created it as an install package. Icon and everything.

    Does anyone know of a way of making it so I do not get the security warning at the application start?

    This is going out to customers and I know the code is safe, there is not alot there, but I don't want the security warning at the front.

    SilverLineCalculator.zip

  8. #8
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Okay, so I have this working now, but I am not sure the registry key is what I really want. It removes ALL access warnings.

    Has anyone had any luck with the install package and creating a key to add the location to the trusted locations on install?

  9. #9
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    So, I think I have this working now. Would appreciate if someone could install the package and let me know if they find any bugs. I have also attached the full copy for any suggestions/improvements in my coding.

    SilverLine Calculator.zip
    SilverLineCalculator Installer.zip

    I have a much larger database than this working, but it is used in house and the attached one is something I want to be able to send out to customers, hence the install package and request for bug finding.

    ~Matt

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access Not Responding
    By bigspace55 in forum Queries
    Replies: 1
    Last Post: 02-28-2013, 01:02 PM
  2. Update recordset - 'Not responding'
    By tariq1 in forum Programming
    Replies: 2
    Last Post: 08-11-2012, 11:33 AM
  3. Access Not Responding
    By Phoenyxsgirl in forum Access
    Replies: 11
    Last Post: 11-25-2011, 11:40 AM
  4. Query Not Responding
    By Lady_Jane in forum Queries
    Replies: 9
    Last Post: 11-09-2010, 01:27 PM
  5. Access Query Not Responding
    By sunharepal in forum Programming
    Replies: 4
    Last Post: 10-22-2010, 10:39 AM

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