peggyweber
asked on
Add a value to a combobox in Access Project Sql Server Backend
I am work with this script that I found on this site however I am getting an error at this point in the script.
Set RS = MyDataBase.OpenRecordset(" dbo.Client ")
I can get it to respond and open a msg/input box where I can add the the new item to Client_Name (a text Field column two). The combo box is bound to column one Client_ID(autonumber) and the table is Client. What I need is for the person to be able to add a new item to this lookup table if it does not exist and choose that item.
The full script is
Private Sub Targeted_Customers_AfterUp date()
Customer_ID_Update = Date
Dim ListData As String, Message As String
Dim MyDB As Database, RS As Recordset
If [Targeted_Customers].Colum n(1) = "<Add New Item>" Then
Message = "Please Enter a New Item" ' Set prompt.
' Display message
ListData = InputBox(Message)
If Not IsNull(ListData) Then
Set MyDataBase = CurrentDb()
Set RS = MyDataBase.OpenRecordset(" dbo.Client ")
RS.AddNew
RS("Client_Name") = ListData
RS.Update
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
End If
[Targeted_Customers].Reque ry '<----Updates the list
End If
End Sub
Set RS = MyDataBase.OpenRecordset("
I can get it to respond and open a msg/input box where I can add the the new item to Client_Name (a text Field column two). The combo box is bound to column one Client_ID(autonumber) and the table is Client. What I need is for the person to be able to add a new item to this lookup table if it does not exist and choose that item.
The full script is
Private Sub Targeted_Customers_AfterUp
Customer_ID_Update = Date
Dim ListData As String, Message As String
Dim MyDB As Database, RS As Recordset
If [Targeted_Customers].Colum
Message = "Please Enter a New Item" ' Set prompt.
' Display message
ListData = InputBox(Message)
If Not IsNull(ListData) Then
Set MyDataBase = CurrentDb()
Set RS = MyDataBase.OpenRecordset("
RS.AddNew
RS("Client_Name") = ListData
RS.Update
RS.Close
Set RS = Nothing
db.Close
Set db = Nothing
End If
[Targeted_Customers].Reque
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I take it your want an ADO equivalent?
(btw - IMHO if you're venturing into ADP development - you should give yourself a reasonable grounding in ADO first - unless you intend to use nothing but default functionality - which again I thinkis a mistake with server data. But then I guess professional developers exist for a reason :-)