I have an unbound form on which there are 3 controls: option group, combo box and a subform. The value of the combo box depends on the value of the option group and the value of link child field depends on the value of the combo box. here is the code:
Expand|Select|Wrap|Line Numbers
- Dim stSQL As String, stCriteria As String, stDocNo As String
- stDocNo = Me.cboDocNo
- If Frame4.Value = 1 Then
- stSQL = "SELECT [DeliveryNotes].[DeliveryNote], [DeliveryNotes].[Consignee], [DeliveryNotes].[Description], "
- stSQL = stSQL & "[DeliveryNotes].[ClientID] FROM [DeliveryNotes]"
- Else
- stSQL = "SELECT [ExpiryDates].[ItemTransID], [ExpiryDates].[InvoiceNo], [ExpiryDates].[Description] "
- stSQL = stSQL & "FROM [ExpiryDates]"
- End If
- Me.cboDocNo.RowSource = stSQL
- Me.DeliveryTrans.LinkMasterFields = stDocNo
- If Frame4.Value = 1 Then
- Me.DeliveryTrans.LinkChildFields = "[DeliveryNoteNo]"
- Else
- Me.DeliveryTrans.LinkChildFields = "[InvoiceNo]"
- End If
- Me.cboDocNo.Requery
Regards
Liveson