Runtime error 3251

  • Thread starter Matt C via AccessMonster.com
  • Start date
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?
 
J

Joshua A. Booker

Matt,

Is Client ID a number or a text field?

It appears to be text because you're converting it to a string. Try putting
quotes around it like this:

21: SearchCriteria = "ClientNo = '" & Criteria & "'"

HTH,
Josh
 
M

Matt C via AccessMonster.com

ClientNo is a number field. According to the MSDN website, this would have to
be converted to a string to be used as criteria for the findfirst method. I
tried your technique anyway and still I am getting the same error. Thanks for
trying though
Matt,

Is Client ID a number or a text field?

It appears to be text because you're converting it to a string. Try putting
quotes around it like this:

21: SearchCriteria = "ClientNo = '" & Criteria & "'"

HTH,
Josh
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
[quoted text clipped - 49 lines]
Can anyone see whats wrong?
 
J

Joshua A. Booker

Matt,

Try:

21: SearchCriteria = "ClientNo = " & Criteria

HTH,
Josh

Matt C via AccessMonster.com said:
ClientNo is a number field. According to the MSDN website, this would have to
be converted to a string to be used as criteria for the findfirst method. I
tried your technique anyway and still I am getting the same error. Thanks for
trying though
Matt,

Is Client ID a number or a text field?

It appears to be text because you're converting it to a string. Try putting
quotes around it like this:

21: SearchCriteria = "ClientNo = '" & Criteria & "'"

HTH,
Josh
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
[quoted text clipped - 49 lines]
Can anyone see whats wrong?
 
M

Matt C via AccessMonster.com

Josh

I have tried the concatination both ways, neither worked, but again, thanks
for trying.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top