Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Posts
    18

    Unanswered: Open Form button not working properly.

    I am currently creating a database that tracks customers, contacts, projects, products, events, reservations and orders.

    I have created a series of forms based upon my tables.

    On the Customer form {this will most likely be my main form} I have buttons that open forms which allow me to add contacts, shipping information and projects to the customer record. All of the buttons work properly with CustomerID being the field which filters the records for the dependent forms. When I open the forms, the CustomerID is already visible in its proper field. However, when I try to add an order, the CustomerID is not visible thus forcing me to enter the CustomerID manually. If I do not enter the CustomerID but add all of the details to the order and close it, then refer to the Orders table, there is no CustomerID. In addition to that, after I've entered the Order information completely {including manually entering the CustomerID} and then close the order form, if I back to the Customer form and click the "Orders" button, it will open the Orders form and the form is filtered, however when I keep the filtered form open, scroll to the next record to add another order, the CustomerID field is blank again.

    Any suggestions?

  2. #2
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    Since your form is basead on the Order table, the CustomerID seems like it is the FK in the table, and therefore your reason why you have to type it by hand.
    For the button opening form2 how did you make it? The wizard? Or manually?
    Here is the VBA code the command button wizard just made
    Code:
    Private Sub Command0_Click()
    On Error GoTo Err_Command0_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "SelectReport"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
    Exit_Command0_Click:
        Exit Sub
    
    Err_Command0_Click:
        MsgBox Err.Description
        Resume Exit_Command0_Click
        
    End Sub
    The SelectReport in quotes is the name of a form I have made
    Ryan
    My Blog

  3. #3
    Join Date
    Aug 2003
    Posts
    18
    Hi rguy84-
    Yes, I used the wizard. That is the exact same code that I used. LOL....I'm going crazy!!!

  4. #4
    Join Date
    Jun 2004
    Location
    Seattle, WA
    Posts
    601
    Rhythm

    I am not syre what to say...
    Ryan
    My Blog

  5. #5
    Join Date
    Aug 2004
    Posts
    1

    things to try

    Not sure exactly how your forms relate to one another. I assume customers table is the "one side" and the orders table holds the "many side".

    Using the wizard to create a button to open the form and choosing to "open form and find specific data to display", will only open to an existing order with a prior entered customerid. It will not create a blank record, pre-entered with customerid if one doesn't already exist.

    If you are trying to add a new record to the orders table for a customer and want the order to have the same value as the prior customer seen on the customer form, you must use the default value property on the customerid field in your orders form.

    Open the orders form in design view, click on the customerid field and open the properties sheet. On the data tab, enter the default value as
    =[Forms]![frmCustomers]![customerid]

    Now when you click the button on the customers form to open the orders form, it will either show the existing order, or a new record with the customerid already entered.

    Hope that helps!

Posting Permissions

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