Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Houston, TX

    Unanswered: Look for related record

    I have th efollowing public sub used in a menu bar to open a form frmBudget. When this sub runs it opens the budget form and filters it based on the record that is currently displayed in the main form. My problem is that there are occasions when there is NO related record in the budget form and I get a parameter box asking for the Budget ID. How can I test for a related record?

    Public Sub openBudget()
    Dim frm As Form
    Set frm = Screen.ActiveForm

    DoCmd.OpenForm "ZZfrmBudgetTest", , , "[protocolID] = " & frm.txtProtocolID, acFormEdit, acWindowNormal

    End Sub

    WHAT I WOULD LIKE TO DO: (Psuedo Code)

    Open form and display records where protocolID = txtProtocolID
    If this equivalce is false then open the form in Add mode.

    Thanks for the help.

    -Mr. Research

  2. #2
    Join Date
    May 2003
    Try this.

    Dim iBUdgetid as integer

    iBudget = Dlookup("BudgetID", "Table1", "protocolID = '" & txtProtocolID & "'")

    If iBudget > 0 then
    Open the form with protocolID = txtProtocolID
    Open the form in add mode
    end if

    Hope this 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