Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397

    Unanswered: Open One Form From Another With Condition

    Hi,

    How can I open one form from another with condition and same form should open individualy without demanding any criteria?

    Here is explaination......

    I have a Main form called "F_InvHead" where all fields over there are unbound. It has subform called "SF_InvFooter" based on a query. The have one-to-many relationship in between. In subform, all the fields are bound fields

    There is another form called "F_SearchPatient" where everthing goes fine.

    I have placed a unbound textbox called "TxtCode" somewhere on the form and user could change its value as per requirement. Basically this code is nothing but a file number for the patient.

    What I am trying to do is when user finds a particular patient on "F_SearchPatient", the file number is appeared in "TxtCode" textbox on it and then user will click a command button upon which invoice form will open "F_InvHead" to create the bill / invoice for that customer.

    For your information, "F_InvHead" have a combo box "CboSelectPatient" placed based on a simple query which displays patient name and its file number in column 0 and 1 respectively. This combo box is to select patient to add for a new invoice.

    When I do simply open "F_InvHead" and make invoice by selecting required partient from "CboSelectPatient", it works smoothly. This is normal routine.

    What I need is when clicked commant button on "F_SearchPatient" from, it should open "F_InvHead" showing the patient file of same customer that was selected on in "F_SearchPatient" form.

    This way my user will select patient on "F_SearchPatient" and just in one click he will have invoice form opened with suggestion to select "this" customer for the invoice. This will same his time as these transaction are bing carried out at hospital receiption.

    I dont know if I described my problem clearly.

    Is there any idea?
    With kind regards,
    Ashfaque

  2. #2
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    When the target form opens, in the Form_Open event, check for OpenArgs If this is null, just open the form normally, if it has a value - write your code to do the necessary actions.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  3. #3
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    I do not have idea about OpenArgs.

    I was trying with below code written behind command button to open F_InvHead form from F_SearchPatient.

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "F_InvHead"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    stLinkCriteria = "[P_FileNo]=" & Forms![F_SearchPatient].Form![TxtCode]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    But it is not helping much.

    I have attached my db here....can someone help me out.

    When clicked over Invoice command btn on search form, I want new record to be added (add new record and select the same customer from to inv form)

    But if Invoice form is being opening independently then it should open normal way so manually new record can be added by clikcing "+" btn on Invoice form.

    Please have a look at the attachement and extend your help as usual.
    Attached Files Attached Files
    With kind regards,
    Ashfaque

  4. #4
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    No worries - I'll have a look.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  5. #5
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    Any news ?
    With kind regards,
    Ashfaque

  6. #6
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    Hi,

    Is there anybody who can help please..
    With kind regards,
    Ashfaque

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I do not have idea about OpenArgs.
    I suggest you find out about OpenArgs NOW.

    Your button can open the form with an openarg, and when the form is opened directly (or opened with code that doesn't supply an openarg) it is opened without one. Your openargs code can then do what you want to achieve and it will only work when the form is opened with an openarg.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    OpenArgs is the last parameter in the DoCmd.OpenForm method. You can use it anyway you like. In the past I have used it to pass one or a list of parameters. If you want to send the patient number to the other form you just add the patient variable to the end of the OpenForm call in the search form.

    Then in the header form you would check Me.OpenArgs to see if anything was sent or not. If you opened the form without passing a patient number then Me.OpenArgs will be null. But if you passed in a patient number then it will be available in Me.OpenArgs.

  9. #9
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397
    Thanks Gents,

    I have sorted out without using OpenArgs. May be it is not the proper way but it gives me the result what I wanted.
    With kind regards,
    Ashfaque

Posting Permissions

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