View Single Post
  #6 (permalink)  
Old April 26th, 2007, 10:59 AM
Grafixx01 Grafixx01 is offline
Authorized User
Join Date: Apr 2007
Location: Fort Bliss, Texas, USA.
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts

Wonder if this would work? I got it from my friends old, corrupted db where he did the same thing that I'm trying:

Dim strID As String, bValid As Boolean
Dim rsRecordset As Recordset

'check for valid record id

strID = txtLogID.Text
bValid = True

If Not IsNumeric(strID) Then
    bValid = False
    If Val(strID) <> Int(Val(strID)) Then
        bValid = False
    End If

    Set rsRecordset = CurrentDb.OpenRecordset("SELECT * FROM DOCUMENTS WHERE Documents.DocID=" & strID, dbOpenDynaset, dbReadOnly)
    If rsRecordset.RecordCount <> 1 Then 'ambiguous record/ does not exist
        bValid = False
        MsgBox "The record number does not exist.", vbInformation, "Invalid Record"
    End If
    Set rsRecordset = Nothing
End If

If Not bValid Then Exit Sub

DoCmd.OpenForm "frmDocumentLog", acNormal, , , acFormEdit, acDialog, strID
DoCmd.Close acForm, Me.Name, acSaveNo

End Sub

Reply With Quote