Results 1 to 3 of 3
  1. #1
    Kivan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    27

    Opening form with defined combobox value

    Hi.

    I have two tables. People and Organization. In the people table you can choose organization from organization table (combobox). People form has fields Name etc. and organization (query IDOrg, OrgName descending).



    I have two forms. First form is frmOrganization with subform of people (members of org). Second form is frmPerson.
    On frmOrganization I would like to have a button which would add new person to organization (this person does not exist in the people table yet, its absolutely new). So after clicking on this button I would like to see frmPerson where I could put new data BUT the name of organization would be there already (taken from frmOrganization).
    And I think it should be like below, but I dont know how to define OpenArgs. I was trying hard, but it seems I'm not skilled enough with VBA.

    Code:
    Private Sub AddNew_Click()
    DoCmd.OpenForm "frmPerson", , , , acFormAdd, , 'There is my issue'
    End Sub
    Thank you for your time .

  2. #2
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    You need to read a bit on openargs (try here)

    Basically it passes a string to the me.openargs property on the object (e.g. forms/reports) it would open.

    so, for instance you could have it like:

    Code:
    Private Sub AddNew_Click() 
    DoCmd.OpenForm "frmPerson", , , , acFormAdd, , "NewUser" 
    End Sub
    Then on frmPerson use the Form_Load event

    Code:
    If me.openargs="NewUser" then
    [forms]![frmperson]![control_name]=[forms]![frmorganisation]![control_name]
    endif

  3. #3
    Kivan is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    27
    Your solution works perfectly. Thanks a lot .

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

Similar Threads

  1. Opening Different Reports on Combobox Selection
    By confusedlilly19 in forum Reports
    Replies: 1
    Last Post: 06-24-2012, 03:46 PM
  2. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  3. VBA: combobox not defined?
    By opopanax666 in forum Programming
    Replies: 3
    Last Post: 08-11-2011, 09:17 AM
  4. Application-defined or object-defined error
    By hawkins in forum Access
    Replies: 6
    Last Post: 07-01-2011, 01:57 PM
  5. Replies: 0
    Last Post: 08-24-2010, 06:38 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