I have many of these. They all work, except one. It is slightly different from the rest. Those two lines of assignments have worked while I was debugging. The first one encountered works. The second one does not work. So at times one of the text boxes has a value and the other is NULL. Both are supposed to have values.
Here is the sub
Expand|Select|Wrap|Line Numbers
- Private Sub cmbSaveClose_Click()
- Dim x As Integer
- x = MsgBox("Are you sure you want to save changes?", 4, "Exit?")
- 'VbNo constant throws back #7
- 'VbYes constant throws back #6
- Me.Txt32 = DLookup("InsuranceCarrierContractID", "ICCDupRecordCheckQ")
- If x = 7 Then
- Exit Sub
- End If
- If IsNull(Me.Txt32) Then
- Me.Txt31 = Form_frmMain.Txt65
- DoCmd.RunCommand acCmdSaveRecord
- ' The preceding code works fine.
- ' Each of the following lines work individually, but only the one executed first works. The other does not appear to execute. I end up with a null in the text box.
- Forms!frmMain.cboInsuranceCarrierContract = Me.InsuranceCarrierContractID
- Forms!frmMain.Txt66 = Me.InsuranceCarrierContractID
- 'The following code works fine.
- DoCmd.Close
- Forms!frmMain!cboInsuranceCarrierContract.RowSource = " SELECT InsuranceCarrierContract.ContractNumber " & _
- " FROM InsuranceCarrierContract " & _
- " ORDER BY InsuranceCarrierContract.ContractNumber;"
- Form_frmMain.cboInsuranceCarrierContract.Locked = False
- Form_frmMain.cboInsuranceCarrierContract.BackColor = Form_frmMain.cboInsuranceCarrier.BackColor
- Else
- Me.Undo
- DoCmd.Close
- End If
- End Sub