Error 2115 whilst performing search (1 Viewer)

tucker61

Registered User.
Local time
Today, 00:55
Joined
Jan 13, 2008
Messages
321
Today's error message is error 2115.

My code below looks to see if a supplier and a delivery reference have already been checked, and if so, brings back the job number in the database.

I then want to code to Cancel what the user was doing and automatically open up that job number, When trying to assign the bookmark, the code gives me Error 2115. "The macro or function set to the beforeupdate or ValidationRule property for this field is preventing the DB from saving the data in the field. "

I assume that this is to do with the data that the operator is entering, so do i just clear the error in the handler ?

Looking in the immediate window, the code is finding the correct job number, but just cannot filter on it.

Any help appreciated.

Code:
Private Sub CboxSup_Code_BeforeUpdate(Cancel As Integer)
On error goto handler
              If Nz(DCount("Delivery_reference", "tblqcnonconformanceEmg", "Delivery_Reference='" & tbReference & "' AND Sup_Code='" & CboxSup_Code & "'"), 0) > 0 Then
                JobNo = DLookup("JOb_ID", "tblqcnonconformanceEmg", "Sup_Code='" & CboxSup_Code & "' AND Delivery_Reference='" & tbReference & "'")
                If MsgBox("Delivery Reference " & Format(tbReference, "0000000") & " And Supplier Code '" & UCase(CboxSup_Code) & "'" & vbNewLine & vbNewLine & "Have already been Input  " & vbNewLine & vbNewLine & "Press ok to go to that original Job to Carry on Inputting!", vbOkay, "Presviously Input") Then
PerformSearch:
        Dim rs As Object
        Dim lngID As Long
        
                If JobNo > 0 Then
                 Me.FilterOn = False
                   Set rs = Me.RecordsetClone
                   With rs
                      .FindFirst "[Job_id]=" & JobNo
                       If .NoMatch Then
                         MsgBox "Sorry, that Job Number does not exists.", vbExclamation, "Job Number Not Found"
                      Else
                        [COLOR="Red"] Me.Bookmark = .Bookmark ' Debug highlights this line[/COLOR]
                      End If
                   End With
                    Set rs = Nothing
                End If
          DoEvents

        End If
End If
Exit Sub

Handler:

        Call LogError(Err.Number, Err.Description, "23", tbReference)
        Forms!frmnonconformance.Visible = True
        Exit Sub
    
End Sub
 

Ranman256

Well-known member
Local time
Today, 03:55
Joined
Apr 9, 2015
Messages
4,339
There's no need to assign bookmarks.
User views the filtered list, then can open a detail form using the selected key,
But the list remains on that record.
bookmark not needed.
 

June7

AWF VIP
Local time
Yesterday, 23:55
Joined
Mar 9, 2014
Messages
5,466
If user has initiated a new record with the CboxSup_Code selection and existing value is found, don't you need to abort the record that was initiated?

Cancel the combobox input and Undo the record initiation.

If this combobox is UNBOUND, then use AfterUpdate event instead.
 

tucker61

Registered User.
Local time
Today, 00:55
Joined
Jan 13, 2008
Messages
321
The Command is a bound column.

Is it just a case of using the undo command ? for the 3 completed fields ?

CboxSup_Code.undo ?
Etc
 

June7

AWF VIP
Local time
Yesterday, 23:55
Joined
Mar 9, 2014
Messages
5,466
Use Cancel = True for the combobox. Then Me.Undo for the record.

If that causes issues, try changing to combobox AfterUpdate event instead of BeforeUpdate. Then probably just need Me.Undo.
 

tucker61

Registered User.
Local time
Today, 00:55
Joined
Jan 13, 2008
Messages
321
Use Cancel = True for the combobox. Then Me.Undo for the record.

If that causes issues, try changing to combobox AfterUpdate event instead of BeforeUpdate. Then probably just need Me.Undo.

That worked.
 

Users who are viewing this thread

Top Bottom