I have a function in my Orders form that test several of the fields to make sure the data in them is correct and creates ancillary records (such as a tracking record) if they haven't been created already. We have recently started co-locating with another
show and sharing revenue for some (but not all) of our exhibitors with this show. I have a table linked to my Companies table that indicates which show we are sharing revenue with for that company and what percentage of revenue they get. I did it that way
to have the flexibility to have similar agreements with multiple shows. Because we may or may not be doing this in any given year, I also have a similar table linked to the orders table. I want Access to prompt the user when an order is created for a company
with the shared designation giving them the option to create a record or not depending on whether we are co-locating and select which show we are sharing with (in the event that someone is shared with more than one show). I created a dialog box to collect
this information and put code in to open that form and populate the fields with the available choices. The problem is that this function closes the form when it's done if there are no problems. I thought that by making the dialog box modal, it would stop
the function until the dialog box is closed, but that doesn't seem to be the case, so I'm losing the RowSource for my combo box. I need a way to get the function to wait until this form is closed (and any record saved) before continuing and closing the form.
My code is below:
'Check to see if this is a revenue-share company
If Me.SplitChecked = False Then 'Hasn't been checked yet.
Dim rsSplits As DAO.Recordset
Set rsSplits = CurrentDb.OpenRecordset("SELECT tblSplits.MasID, tblSplits.SisterShowID, tlkpSisterShows.SisterShowName, tblSplits.SplitPercent" & _
" FROM tblSplits INNER JOIN tlkpSisterShows ON tblSplits.SisterShowID = tlkpSisterShows.SisterShowID WHERE MasID = " & Me.exh_masid, dbOpenDynaset, dbSeeChanges)
If rsSplits.RecordCount > 0 Then 'Company is designated as a shared company
DoCmd.OpenForm "fdlgCreateOrderSplit"
'Pass the OrderID
Forms!fdlgCreateOrderSplit!OrderID = Me.OrderID
'Set the record source for the Combo Box
Forms!fdlgCreateOrderSplit!cboSisterShow.RowSource = "SELECT SisterShowID, SisterShowName, SplitPercent FROM rsSplits UNION " & _
"SELECT 0 AS SisterShowID, 'None' AS SisterShowName, 0 AS SplitPercent ORDER BY SisterShowID"
Forms!fdlgCreateOrderSplit!cboSisterShow.SetFocus
End If
Me.SplitChecked = True 'We don't need to check this record again.
End If