Change form and display record from previous form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • erniemack
    New Member
    • Mar 2010
    • 10

    Change form and display record from previous form

    I am using a combobox lookup on one form and would like to use the value returned from that lookup to display a record on another form. Here is the select statement:

    SELECT tblJob.JobNumbe r, tblJob.Customer Name, tblJob.PO, tblJob.[Customer Motor #], tblJob.assm_sta tus FROM tblJob WHERE (((tblJob.assm_ status)<>"Done" )) ORDER BY tblJob.Customer Name;

    Column 1 is the bound column

    Here is the after update code

    Private Sub CustomerSearch_ AfterUpdate()
    On Error GoTo Err_customersea rch_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim acct As Integer
    acct = Me.CustomerSear ch.Value
    stDocName = "frmOESJOBmaint "
    DoCmd.OpenForm stDocName, , , "[jobnumber] = acct"
    Exit_customerse arch_Click:
    Exit Sub
    Err_customersea rch_Click:
    MsgBox Err.Description
    Resume Exit_customerse arch_Click
    End Sub

    When I run it asks for the parameter value of "acct" and if I key the jobnumber in it will display the proper form and record. Please help me understand what is wrong.

    Thanks
  • Kinwang2009
    New Member
    • Feb 2010
    • 22

    #2
    Hi erniemack,

    Try below code. I hope it should work but i didn't try it.
    Private Sub CustomerSearch_ AfterUpdate()
    On Error GoTo Err_customersea rch_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim acct As Integer
    acct = Me.CustomerSear ch.Value
    stDocName = "frmOESJOBmaint "
    DoCmd.OpenForm stDocName, , , "[jobnumber] = YOURFORM!acct"
    Exit_customerse arch_Click:
    Exit Sub
    Err_customersea rch_Click:
    MsgBox Err.Description
    Resume Exit_customerse arch_Click
    End Sub
    Replace YOURFORM with the name of Form which contain CustomerSearch Combobox.

    Hope this helps

    Comment

    • erniemack
      New Member
      • Mar 2010
      • 10

      #3
      I used
      DoCmd.OpenForm stDocName, , , "[jobnumber] = " & acct
      It worked. Thanks for the response

      Comment

      Working...