Catching and Changing Error 2105

webcrab

Registered User.
Local time
Today, 15:11
Joined
Feb 18, 2009
Messages
36
Hi!
In My Form , there is a textboxe that get's orders numbers. this textboxes is bound to a unique field so if the user writes a number that is already in use there is a pop messege that says: "you can't go to the specified record."
The Pop up messge pops afetr clicking the "add Order" button
I would like to catch that error and change it's text a little bit,
How Can I do this?
thanx a lot!
 
Hi there

try this on the texboxe's "before update event"
When the user fills the textbox with a duplicate number and tries to move to the next textbox on the form, a message box will pop up and inform them
Have a look at the following code.

Code:
' Code Start
Dim nodata As String
nodata = Nz(DLookup("[YOUR FIELD NAME]", "[YOUR TABLE NAME]"), "")
If nodata <> "" Then
MsgBox "The ID you Are Trying To Enter is Currently In Use" & vbCrLf & _
"Please enter Another ID", vbInformation, "Warning Duplicate ID Enterd"
Cancel = True
 
Me.YOUR FIELD NAME.Undo
Else
End If
 
' Code End


Regards
Rob :)
 
Hi Man thnax!
But the problem is that the MsgBox Pops in every number i Put in - including the ones who aren't in the table yet..
Am I doing anything wrong here?

My field name is: OrderId
My table Name is: Banks
MytextBox name is" Order_ID_text
I shell say that the order's number is a string type

If you'll help me with that.. well, your my king!
 
hi try this... just to clarify the field you type the number in is bound to table banks and the field is called orderid ?

Code:
' Code Start
Dim nodata As String
nodata = Nz(DLookup("[OrderId]", "[Banks]"), "")
If nodata <> "" Then
MsgBox "The ID you Are Trying To Enter is Currently In Use" & vbCrLf & _
"Please enter Another ID", vbInformation, "Warning Duplicate ID Enterd"
Cancel = True
 
Me.OrderId.Undo
Else
End If
 
' Code End
 
Hi Rob!
well, all the things you wrote are true but i have noticed two things:

1.At the last row of the code I have to use the control name for the undo
and not the fieldname in the table
so
I think it should be:
Me.Order_Id_text.undo
instead of

Me.OrderId.undo
Because It doesn't recognize the undo method for OrderId(the fieldname in table)

2.But still, It doesn't work properly..
 
Hi there Sorry i Was on beer late last night lolll

the way to do this is
first make a select query on table banks and in the orderid field criteria place the following

[forms]![YOUR FORM NAME]![Order_Id_text]

THEN

Code:
' Code Start
Dim nodata As String
nodata = Nz(DLookup("[OrderId]", "[YOUR QUERY NAME]"), "")
If nodata <> "" Then
MsgBox "The ID you Are Trying To Enter is Currently In Use" & vbCrLf & _
"Please enter Another ID", vbInformation, "Warning Duplicate ID Enterd"
Cancel = True
 
[COLOR=black]Me.Order_Id_text.undo
[/COLOR]Else
End If
 
' Code End

hope this makes workss for you (head pounding here loll)

rob :)
 
Well..
That worked only now i can't browse back and forth (with customized buttons) in the older orders .. that is why i thought of catching the specific error (2105)

Is there anyway I can fix this out?
 

Users who are viewing this thread

Back
Top Bottom