Results 1 to 3 of 3
  1. #1
    raghuprabhu is offline Novice
    Windows Vista Access 2003
    Join Date
    Apr 2012
    Posts
    8

    How to open forms

    Hi All,

    I have attached a small database (Access 2003). This has table to show
    customer details and order details.

    It also has 3 forms and 2 subforms. The forms are as follows

    frmAddNewCustomer is to input new customer
    frmAddNewOrderDetails is to input new orderlines by customers
    frmShowAllByCustNo which show the customers and the orders

    In the table "tblCustInfo" I have three customers at present
    ID IDNumber Surname GivenNames
    1 2012001 Prabhu Raghu
    2 2012002 Jain Sanjay
    3 2012003 Kamath Sunil

    In the table "tblPurOrder" I have the following data.



    ID tblCustInfoID PurOrderNo purDate
    1 1 201206001 1/06/2012
    2 1 201206002 1/06/2012
    3 2 201206003 1/06/2012
    4 2 201206004 1/06/2012

    when I open form frmShowAllByCustNo it prompts the user for the customer number. If I input 2012001 or 2012002 order lines will show.

    If I input 2012003 there are no records to show.

    My first question is how do I make a message box popup and give the message "This customer does
    not have and order lines" and then the form "frmAddNewOrderDetails " popup when customer number 2012003 is input?

    My second question is how do I make a message box popup and give the message "This customer does
    not exist in the tblCustInfo" and then the form "frmAddNewCust" popup when customer number 2012004 is input?

    Thanks
    Raghu Prabhu
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Can have code like this behind a form but not a subform.
    Code:
    Private Sub Form_Load()
    If Me.RecordsetClone.RecordCount = 0 Then
        MsgBox "No records"
        DoCmd.Close acForm, Me.Name
    End If
    End Sub
    Better would be menu/switchboard form (or a navigation form, which I have never used) with buttons that will open the forms with macro or VBA code. The current setup requires opening the form directly from the navigation pane. The menu form would be set to open by default when the project opens.

    You are also using query input parameter prompts. I never use those because cannot validate user input. Better to use forms with controls for user input of search/filter criteria then query parameters refer to the form controls for input. Entries to controls can be validated by code and properties.

    Suggest you review some working projects to get an understanding of this structure. Check out the templates available from MS and other sources. A well-known one is the Northwind database. It is used extensively in tutorials.

    Check out some of the video tutorials at http://datapigtechnologies.com/AccessMain.htm
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    raghuprabhu is offline Novice
    Windows Vista Access 2003
    Join Date
    Apr 2012
    Posts
    8
    Thanks will try to do as you suggested.

    Raghu

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

Similar Threads

  1. unable to open locked forms
    By jhargram in forum Forms
    Replies: 1
    Last Post: 02-29-2012, 04:23 PM
  2. HOW TO: Button to open different forms?
    By Natan in forum Programming
    Replies: 5
    Last Post: 08-01-2011, 01:58 PM
  3. Use MsgBox to open different forms
    By blueraincoat in forum Forms
    Replies: 10
    Last Post: 03-13-2011, 10:40 PM
  4. Command buttons to Open Forms
    By Ace Pioneer in forum Access
    Replies: 1
    Last Post: 11-30-2010, 06:32 AM
  5. too many forms open
    By Jaad in forum Database Design
    Replies: 0
    Last Post: 02-22-2010, 08:39 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