Hello,
I have a Form and a dialog box. The form consists of a Main Form and a Subform, Both have record sources from different queries and they are linked by a field named fkOrderID. The subform is a scrolling type. The main Form contains a field named InvoiceNumber.
The dialog Box consist of an Unbound combobox that has as record source the Orders Table, which stores the value for the field InvoiceNumber. Also it has a Button with the following code:
Private Sub EditSaleOrder_Click()
If IsNull(CboInvoiceNumber) Then
MsgBox ("Please Enter an Invoice Number from the List")
Exit Sub
End If
DoCmd.OpenForm "SalesOrderEntryFormEditing", acNormal, , "[InvoiceNumber]=" & Me.[CboInvoiceNumber], acFormEdit
DoCmd.Close acForm, Me.Name
End Sub
When you press the button it opens the form at the given Invoice value so that we can edit the record. This works fine as long as the original record has values in the form and the subform. However if for any reason the subform has no values then pressing the button opens a new record even though the combobox contains the Invoice Number that I want to edit and the Table Orders also contains the InvoiceNumber and parts of the Information from the Main Form. I am not sure what I am doing wrong. I would really appreciate it if you could help me. Thank you in advance for your time and efforts.