Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2010
    Posts
    85
    Provided Answers: 2

    Angry Unanswered: How do I open one form from another based on 2 criteria in the original form.

    Hello Group

    I am new here and have had a look around and already found answers to some long lasting issues I have had. However I have one problem that I can't seem to sort out.

    I have a form that I want to use to open a second form (to display more detailed information). The original form has two criteria that I want to use so that the second form opens at the correct record. The conditions are a unique CustomerID and a not unique MachineNo. Essentially a particular CustomerID will have only one machine with a not unique MachineNo but they may have multiple machines each with its own unique MachineNo.

    I hope that is clear

    The code I am trying to use is this
    Code:
    Private Sub MachineConfig_Click()
    On Error GoTo Err_MachineConfig_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
        stLinkCriteria = ""
        stDocName = "Machine Configurations"
        
        stLinkCriteria = "[MachineNo]=" & "'" & Me![MachineNo] & "'" & "AND"
        stLinkCriteria = "[CustomerID]=" & "'" & Me![CustomerID] & "'"
        
        strLinkCriteria = Left(strLinkCriteria, Len(strLinkCriteria))
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_MachineConfig_Click:
        Exit Sub
    
    Err_MachineConfig_Click:
        MsgBox Err.Description
        Resume Exit_MachineConfig_Click
        
    End Sub
    What happens is that when the second form opens it does not open with the correct MachineID record displayed.

    If the first form has the record for MachineID 0810-0101 displayed, and the customer has multipe machines (say with numbers 0810-0101, 22987, 0910-0090) the second form may not necessarily open with the correct record (in this case 0810-0101) displayed.

    Can anyone advise on haw I might be able to resolve thsi.

    My thanks in advance for any assistance given

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    first look

    stLinkCriteria = "[MachineNo]=" & "'" & Me![MachineNo] & "'" & "AND"
    stLinkCriteria = "[CustomerID]=" & "'" & Me![CustomerID] & "'"

    change to

    stLinkCriteria = "[MachineNo]=" & "'" & Me![MachineNo] & "'" & "AND"
    stLinkCriteria = stLinkCriteria & "[CustomerID]=" & "'" & Me![CustomerID] & "'"

    and put some spaces after the AND " AND "
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Sep 2010
    Posts
    85
    Provided Answers: 2

    Thumbs up

    Hi Myle

    GENIUS

    It works a treat!

    Many, many thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •