I have a form (frmJob) that has a combobox (cmbCompany). If a new company is not in the table the NotInList code opens another form (frmCompany) and a new company is added into the textbox (txtCoName).
The code below is the code that closes the frmCompany after entering new company.
The first part of the code (Add new company into table) works and adds the new company into table but the second part (Add new company into frmJob) does not, and the new company does not appear in the cmbCompany combobox. Note: frmJob remains open while data is entered into frmCompany.
How can I get the second portion of the code to work? Thanks Sandy
The code below is the code that closes the frmCompany after entering new company.
The first part of the code (Add new company into table) works and adds the new company into table but the second part (Add new company into frmJob) does not, and the new company does not appear in the cmbCompany combobox. Note: frmJob remains open while data is entered into frmCompany.
How can I get the second portion of the code to work? Thanks Sandy
Code:
Public RemCompany As String
Private Sub cmdCloseCompany_Click()
‘‘FIRST PORTION - Add new company into table
Dim dbCom As Database
Dim recCom As Recordset
Set dbCom = CurrentDb
Set recCom = dbCom.OpenRecordset("Select * from tblCompany")
recCom.AddNew
recCom("CoName") = Me.txtCoName
recCom.Update
Set recCom = Nothing
Set dbCom = Nothing
‘‘SECOND PORTION - Add new company into frmJob (which is open)
RemCompany = Forms!frmCompany.txtCoName
DoCmd.Close acForm, "frmCompany"
Forms!frmJob.Undo
Forms!frmJob.cmbCompany = RemCompany
Me.Refresh
End Sub
[\Code]