Recordcount not working in dialog but in normal view

timothyd

Registered User.
Local time
Today, 03:12
Joined
Feb 9, 2010
Messages
41
I have a very odd situation:

I have a VBA code segment that I want to exit out if the recordcount = 0. This works great when I am in normal view, but for some reason it doesn't work when I am in dialog view. Has anyone ever experienced such a strange thing? And if so, is there a way to fix it? Thanks.
 
I know for a fact that the recordset has a record in it and it doesn't exit if it
is in normal view, but it does exit in the recordcount portion when in dialog view.

Code:
Private Sub Item_Name_LostFocus()
  
  On Error GoTo errhandler
  
  Dim rsClone As Recordset
  Dim loopExit As Boolean
  
  Set rsClone = Me.RecordsetClone
  loopExit = False
  
  Me.Item_Name.BackColor = vbWhite
  Pri_Item_Name_Unique = True
  
  If rsClone.RecordCount = 0 Then
    GoTo ExitHere
  End If
  
  If Me.Item_Name.Value <> "" And Not IsNull(Me.Item_Name) Then
    rsClone.FindFirst "[Item Name] = '" & Me.Item_Name.Value & "'"
    If Not rsClone.NoMatch Then
      MsgBox "The name you have entered is not unique and is currently in use. " & _
               "Please enter a different name.", vbOKOnly, "Invalid Name"
      Me.Item_Name.BackColor = RGB(255, 80, 80)
      Pri_Item_Name_Unique = False
    End If
  End If
  
ExitHere:
  
  Set rsClone = Nothing
  
  Exit Sub
  
errhandler:
  
  With Err
      MsgBox "Error " & .Number & vbCrLf & .Description, _
            vbOKOnly Or vbCritical, "Item Name Error"
  End With
  
End Sub
 
Well i figured it out. When i was opening the form improperly from another form.
 

Users who are viewing this thread

Back
Top Bottom