Results 1 to 4 of 4
  1. #1
    eacollie is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    10

    Opening form with passing argument

    I am trying (unsuccessfully) to open a form from another form by passing a date argument.



    On the first form:
    Code:
    Public Sub OpenAppointmentForm(vStartDate As Date)
        Dim stDocName As String
        Dim stLinkCriteria As String
        
        stDocName = "frmDayCalendarMC"
        stLinkCriteria = vStartDate
        MsgBox (stLinkCriteria)
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    This seems to work OK, as I get a message box with the correct date.
    The Load event for the second form is:
    Code:
    Private Sub Form_Load()
        If Not IsNull(Me.OpenArgs) Then
                Me.txtDate = Me.OpenArgs
        Else
            MsgBox "No argument passed"
            '-- Nothing passed, just open on the 1st record
        End If
    End Sub
    I get the message that no argument was passed.

    I'm trying to set Me.txtDate on my second form to the date of the passed argument.

    Any help would be greatly appreciated....thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The OpenArgs argument is the 7th parameter, not the 4th.
    DoCmd.OpenForm stDocName, , , , , , stLinkCriteria

  3. #3
    eacollie is offline Novice
    Windows XP Access 2007
    Join Date
    Jun 2011
    Posts
    10
    Thanks RuralGuy! That took care of the problem.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Do you want to use the Thread Tools at the top of the thread and mark this thread as Solved?

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

Similar Threads

  1. Pass argument to a report from VBA?
    By degras in forum Reports
    Replies: 2
    Last Post: 01-25-2011, 11:13 AM
  2. Compile Error: Argument Not Optional
    By bg18461 in forum Access
    Replies: 1
    Last Post: 12-01-2010, 08:47 AM
  3. Passing value from one form to another
    By Molly152 in forum Forms
    Replies: 4
    Last Post: 11-16-2010, 11:03 AM
  4. Invalid Argument Error
    By koper in forum Access
    Replies: 2
    Last Post: 06-14-2010, 11:22 AM
  5. Passing a form name to a subroutine
    By trb5016 in forum Programming
    Replies: 0
    Last Post: 02-01-2010, 12:03 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