Hello,
I have got a form with 2 Combo boxes. ComboA gives a company name. ComboB gives the account number. Each company can have more than 1 different account number. Upon selecting a company the list of account numbers associated with that company is displayed. The Company and Account No are stored in a ddlCompany table.
If i enter a new company in the [Company] (ComboA) field i have some vb set up to add that to the database and add its accounts number. You are then able to use the form as normal.
It is possible that a new account number for an existing company is set up. I need to simply enter this in the [AccountNo] (ComboB) and have it added to the ddlCompany table in the background. Nothing has changed other than the field names from the Not in list segments of code. For a reason i am not at present understanding receiving an error message saying the item is not in the list and to select one that is. The only thing i can think of is the source of the [AccountNo] field. I have included the source of the [AccountNo] field and the Notinlist code.
[AccountNo] Source----
SELECT ddlCompany.CompanyName, ddlCompany.VFCorporateId FROM ddlCompany WHERE (((ddlCompany.CompanyName)=[forms]![tblIssues]![company]));
NOTInList Code ----
Private Sub VF_Corp_ID_NotInList(NewData As String, Response As Integer)
If MsgBox("Do you really want to add this item?", vbQuestion + vbYesNo) = vbYes Then
Dim DB As Database
Dim sSQL As String
sSQL = "INSERT INTO ddlCompany ( CompanyName, VFCorporateId ) SELECT tblIssues2.Company, tblIssues2.VF_Corp_ID FROM tblIssues2 WHERE (((tblIssues2.Issue_No)=123));"
Set DB = CurrentDb
DB.Execute sSQL
DB.Close
Set DB = Nothing
' Continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
On Error GoTo Err_VF_Corp_ID_NotInList
Exit_VF_Corp_ID_NotInList:
Exit Sub
Err_VF_Corp_ID_NotInList:
MsgBox Err.Description
Resume Exit_VF_Corp_ID_NotInList
End Sub
I hope someone has some ideas.
Cheers for any help.
Craig.
I have got a form with 2 Combo boxes. ComboA gives a company name. ComboB gives the account number. Each company can have more than 1 different account number. Upon selecting a company the list of account numbers associated with that company is displayed. The Company and Account No are stored in a ddlCompany table.
If i enter a new company in the [Company] (ComboA) field i have some vb set up to add that to the database and add its accounts number. You are then able to use the form as normal.
It is possible that a new account number for an existing company is set up. I need to simply enter this in the [AccountNo] (ComboB) and have it added to the ddlCompany table in the background. Nothing has changed other than the field names from the Not in list segments of code. For a reason i am not at present understanding receiving an error message saying the item is not in the list and to select one that is. The only thing i can think of is the source of the [AccountNo] field. I have included the source of the [AccountNo] field and the Notinlist code.
[AccountNo] Source----
SELECT ddlCompany.CompanyName, ddlCompany.VFCorporateId FROM ddlCompany WHERE (((ddlCompany.CompanyName)=[forms]![tblIssues]![company]));
NOTInList Code ----
Private Sub VF_Corp_ID_NotInList(NewData As String, Response As Integer)
If MsgBox("Do you really want to add this item?", vbQuestion + vbYesNo) = vbYes Then
Dim DB As Database
Dim sSQL As String
sSQL = "INSERT INTO ddlCompany ( CompanyName, VFCorporateId ) SELECT tblIssues2.Company, tblIssues2.VF_Corp_ID FROM tblIssues2 WHERE (((tblIssues2.Issue_No)=123));"
Set DB = CurrentDb
DB.Execute sSQL
DB.Close
Set DB = Nothing
' Continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
On Error GoTo Err_VF_Corp_ID_NotInList
Exit_VF_Corp_ID_NotInList:
Exit Sub
Err_VF_Corp_ID_NotInList:
MsgBox Err.Description
Resume Exit_VF_Corp_ID_NotInList
End Sub
I hope someone has some ideas.
Cheers for any help.
Craig.