Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display new record in Combo Box ?

Status
Not open for further replies.

101287

MIS
Apr 8, 2006
189
US
I have a combo box that enable the user to add a category. When the category is added I would like to add the new record and display the record added in the form.

I have the following code but is not enabling me to display the added record. Any suggestions please.

ivate Sub BudgetCategories_AfterUpdate()
End Sub

Private Sub BudgetCategories_BeforeUpdate(Cancel As Integer)
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[BudgetCategories] = " & "'" & Me.BudgetCategories & "'"
If Not rs.EOF Then
Forms!frmBudgetCategories!JanBudget = rs![JanBudget]
Forms!frmBudgetCategories!FebBudget = rs![FebBudget]
Forms!frmBudgetCategories!MarBudget = rs![MarBudget]
Forms!frmBudgetCategories!AprBudget = rs![AprBudget]
Forms!frmBudgetCategories!MayBudget = rs![MayBudget]
Forms!frmBudgetCategories!JuneBudget = rs![JuneBudget]
Forms!frmBudgetCategories!JulyBudget = rs![JulyBudget]
Forms!frmBudgetCategories!AugBudget = rs![AugBudget]
Forms!frmBudgetCategories!SeptBudget = rs![SeptBudget]
Forms!frmBudgetCategories!OctBudget = rs![OctBudget]
Forms!frmBudgetCategories!NovBudget = rs![NovBudget]
Forms!frmBudgetCategories!DecBudget = rs![DecBudget]
End If

End Sub
 
Sorry forgot to include the code that add the item that is not in the combo box.

Private Sub BudgetCategories_NotInList(NewData As String, Response As Integer)
''Response = 2
Set DB = DBEngine.Workspaces(0).Databases(0)
Set rs = DB.OpenRecordset("tblBudgetCategories", DB_OPEN_DYNASET)
rs.AddNew
rs![BudgetCategories] = NewData
rs![JanBudget] = 0
rs![FebBudget] = 0
rs![MarBudget] = 0
rs![AprBudget] = 0
rs![MayBudget] = 0
rs![JuneBudget] = 0
rs![JulyBudget] = 0
rs![AugBudget] = 0
rs![SeptBudget] = 0
rs![OctBudget] = 0
rs![NovBudget] = 0
rs![DecBudget] = 0
rs.Update
Me.Bookmark = rs.Bookmark
Response = DATA_ERRADDED
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top