Hello again, I have a textbox on a form where the user enters in a unique tag number. I have it set up in the table that it has to be a unique number, but this shows them the error once the record is complete. What i am trying to do is error check it one the user enters it in. I have two screens that will use this code. I have it working on one form, but for some reason it will not work on the other (code is pretty much identical). this is the code that works. The only difference between this and the one that does not work is the table name (tblPSA) and feild names (tagno). The one that does not work gives me the msgbox all the time.
Code:
Private Sub Tag_No_Lostfocus() Dim rst As Object Dim db As Object Dim intmsg As Integer 'checking if tag already exists Set db = CurrentDb Set rst = db.openrecordset("bags recieved") If blnTest = False Then If rst.RecordCount <> 0 Then rst.MoveFirst Do While Not rst.EOF If rst("tag no").Value = Me.Tag_No.Value Then intmsg = MsgBox("That tag has already been used, you cannot add the tag again.", vbOKOnly, "Tag Error") blnTest = True End If rst.MoveNext Loop End If End If rst.Close Set rst = Nothing Tag_No.DefaultValue = Me.Tag_No.Value + 1 End Sub
Comment