M
Matt C via AccessMonster.com
I am running a vb script, such that when you type a value into the combo box
that is not already present, it will attempt to add the value in that combo
box, to the table from which the combo box has it's source.
A log has a client, the value of which it takes from a table of clients via a
combo box. The Log will also have a client contact, this is not necessarily
the same for each client, but a default is offered, corresponding to the same
client ID. If the value entered differs from the combo box, a message box is
displayed asking if the user wishes to make it the default. If the user
clicks yes, I want to look up the relevant client ID from the client combo
box, and add the default client to that record from the second combo box.
---------------------------------------------------------------------------
01: Private Sub DefaultClient_AfterUpdate()
02: ClientContact.Value = DefaultClient.Column(1)
03: End Sub
04: ---------------------------------------------------------------------
05: Private Sub DefaultClient_Enter()
06: DefaultClient.Value = ClientID.Value
07: End Sub
08: ---------------------------------------------------------------------
09: Private Sub DefaultClient_NotInList(NewData As String, Response As
Integer)
10: Dim dbs As Database
11: Dim rst As DAO.Recordset
12: Dim Criteria, SearchCriteria As String
13:
14: If vbNo = MsgBox(UCase(NewData) & " is not the Default Contact,
would you like to add it?", vbYesNo 15: + vbQuestion, "New Client") Then
16: Response = acDataErrDisplay
17: Else
18: Set dbs = CurrentDb()
19: Set rst = dbs.OpenRecordset("Client")
20: Criteria = Str(Me!ClientID)
21: SearchCriteria = "ClientNo = " + Criteria
22: rst.FindFirst SearchCriteria
23: rst.edit
24: rst!ClientContact = NewData
25: rst.Update
26: rst.close
27: Response = acDataErrAdded
28: End If
29: End Sub
Adding an item to the list and letting this script run brings up the error:
Runtime error 3251
user operation is not supported for this type of object.
when i click Debug, it highlights line 22 as the one with the error!
Can anyone see whats wrong?
that is not already present, it will attempt to add the value in that combo
box, to the table from which the combo box has it's source.
A log has a client, the value of which it takes from a table of clients via a
combo box. The Log will also have a client contact, this is not necessarily
the same for each client, but a default is offered, corresponding to the same
client ID. If the value entered differs from the combo box, a message box is
displayed asking if the user wishes to make it the default. If the user
clicks yes, I want to look up the relevant client ID from the client combo
box, and add the default client to that record from the second combo box.
---------------------------------------------------------------------------
01: Private Sub DefaultClient_AfterUpdate()
02: ClientContact.Value = DefaultClient.Column(1)
03: End Sub
04: ---------------------------------------------------------------------
05: Private Sub DefaultClient_Enter()
06: DefaultClient.Value = ClientID.Value
07: End Sub
08: ---------------------------------------------------------------------
09: Private Sub DefaultClient_NotInList(NewData As String, Response As
Integer)
10: Dim dbs As Database
11: Dim rst As DAO.Recordset
12: Dim Criteria, SearchCriteria As String
13:
14: If vbNo = MsgBox(UCase(NewData) & " is not the Default Contact,
would you like to add it?", vbYesNo 15: + vbQuestion, "New Client") Then
16: Response = acDataErrDisplay
17: Else
18: Set dbs = CurrentDb()
19: Set rst = dbs.OpenRecordset("Client")
20: Criteria = Str(Me!ClientID)
21: SearchCriteria = "ClientNo = " + Criteria
22: rst.FindFirst SearchCriteria
23: rst.edit
24: rst!ClientContact = NewData
25: rst.Update
26: rst.close
27: Response = acDataErrAdded
28: End If
29: End Sub
Adding an item to the list and letting this script run brings up the error:
Runtime error 3251
user operation is not supported for this type of object.
when i click Debug, it highlights line 22 as the one with the error!
Can anyone see whats wrong?