2
votes

I am curious whether it is possible that when i load a record in one of my forms and i choose to add a quote for that record selected, so i choose add quote (button) which takes me to my quote page. i would then like the form to auto load the record i had previously selected in the other form.

Client Form:

enter image description here

Quote Form: enter image description here Here is the data flow: Record Selected ("Add Job") > Click "Add Items" button > "Items List" loads > the record i previously selected in "Add Job" is then auto loaded.

the feild that will need loading are "Project ID" & "Client name"

1
In what language are you trying to do this? Please edit in your code where you are trying to do this.user6120842
Sorry this would be in microsoft Access - so using VBA code and system functionsMatt H

1 Answers

1
votes

Use OpenArgs argument of the DoCmd.OpenForm method

enter image description here


  • When you click Add Quotes button to open Quotes form, send the details/linked ID via openArgs parameter.
  • In Quotes form load event, you can get the details passed using Me.OpenArgs

See below sample code


On Add Quotes button click

Private Sub AddQuotes_Click()

    DoCmd.OpenForm "frmQuotes", OpenArgs:=me.ClientID

End Sub

Quotes form

Private Sub Form_Load()
    Dim varArgs

    varArgs = Me.OpenArgs

    'Fill the controls with recordset data
    If Not IsNull(varArgs) Then
        With CurrentDb.OpenRecordset("SELECT * FROM tblClients WHERE ClientID = " & varArgs, dbOpenForwardOnly )
                Me.ClientID = !ClientID
                Me.ClientName = !ClientName
                Me.ClientAddress = !ClientAddress
                Me.ClientPhone = !ClientPhone
                Me.ClientEmail = !ClientEmail
            .Close
        End With
    End If

End Sub