Results 1 to 2 of 2
  1. #1
    Lupson2011 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    68

    Opening Forms Multiple Arguements

    Hi



    Having a Friday brain moment.

    Am trying to open a form to display specific information, in this case, by Year End and by Organisation. So I want to show the year end figures for that organisation. I have tried one arguement, but now realise I need both arguements, which I assume is Year End and Organisation.

    The two fields I am working with are YearEnd and Trust1..dont suppose someone is not having a brain moment and let me know the line of code to put underneath the button?

    THanks

    Lupson2011

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Simple code to demonstrate how to open a form with multiple criteria to display records.

    here is a simple code where I use employee_Name(e_name) and Date of birth(b_date) as criteria to open employee form (Table6).






    Code:
    Private Sub Command9_Click()
    Dim strCriteria As String
    Dim strDocname As String
    
    strDocname = "Table6"
    
    If IsNull(Me.Text10) Then
        If Not IsNull(Me.Text12) Then
                strCriteria = "e_name='" & Me.Text12 & "'"
        End If
    End If
    If IsNull(Me.Text12) Then
        If Not IsNull(Me.Text10) Then
            strCriteria = "b_date=#" & Me.Text10 & "#"
        End If
    End If
    If Not IsNull(Me.Text10) Then
        If Not IsNull(Me.Text12) Then
            strCriteria = "b_date=#" & Me.Text10 & "# And e_name='" & Me.Text12 & "'"
        End If
    End If
    
    
    If Len(strCriteria) > 0 Then
        DoCmd.OpenForm strDocname, , , strCriteria
    Else
        MsgBox "Select a criteria"
    End If
        
    End Sub

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

Similar Threads

  1. Multiple forms or embedded sub-forms
    By Juicejam in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:31 AM
  2. Replies: 3
    Last Post: 04-10-2011, 01:36 PM
  3. Forms opening on new record entry
    By daddylongtoe in forum Forms
    Replies: 4
    Last Post: 06-28-2010, 04:15 AM
  4. Access freezes when opening forms
    By thorpef1 in forum Access
    Replies: 0
    Last Post: 01-04-2010, 04:48 PM
  5. Replies: 4
    Last Post: 10-26-2009, 05:27 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