Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    2

    Unanswered: Openargs question

    First let me say Hi, and i hope you can help.

    I have used access previously but not for a while and I have been tasked with creating a database to hold some customer information but have hit a slight snag. here is what i'm trying to do:

    I have two tables Customer Details and Requests.

    The customer details has an auto number field to offer a unique customer ID for each customer. In the customer details form i have a button to open the requests form. What i am trying to acheive is when this button is presses it opens the requests form and populates the Customer ID field on the opened form.

    From researching how to do this it looks like i need to use and open argument but i am a complete novice when it comes to code.

    If anyone can help it would be much appreciated. If you need any information just let me know.

    Thanks

    Carl.

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You need to clarify a bit here. When you open the second form, are you wanting to open a new record and place the CustomerID in the corresponding field, or are you looking for an existing record that has the matching CustomerID?
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Jan 2009
    Posts
    2
    Thanks for the response.

    When i click the button it should create a new record and insert the ID number.

    Thanks

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Okay! Code for the button on your Customer Detaiils form:
    Code:
    Private Sub OpenRequestFormButton_Click()
      DoCmd.OpenForm "RequestFormName", acNormal, , , , , Me.CustomerID
    End Sub
    And in the code module for the Requests form:
    Code:
    Private Sub Form_Load()
     If Not IsNull(Me.OpenArgs) Then
      DoCmd.GoToRecord , , acNewRec
      Me.CustomerID = Me.OpenArgs
     End If
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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