Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / February 2007

Tip: Looking for answers? Try searching our database.

flag a file that exist?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jane - 09 Feb 2007 16:56 GMT
I have a form that I enter serial numbers in.  I was wondering if there is a
way to tell if a number has already been entered.  I would like something
that would tell me the number already exist or something like that, and have
the option to view that record. Can this be done?  If so how would I do this.
I'm still learning access.  There is so much more to learn.  Thanks in
advance.
Jane
Klatuu - 09 Feb 2007 19:13 GMT
Use the Before Update event of the control where you enter the serial number.
The code below will ask the user if they want to cancel the entry or view
the existing record.  Since I don't know the names you are using, these are
made up for example purposes.

Private Sub txtSerNo_BeForeUpdate(Cancel As Integer)

   If Not IsNull(DLookup("[SerialNumber]","TableNameHere", "[SerialNumber]
= '" & Me.txtSerNo) Then    'The serial number is already in the table
       Cancel = True      'Cancels updating the field
       If MsgBox(Me.txtSerNo & " Is in the Table" & vbNewLine & "OK to View
the Record", vbQuestion + vbOkCancel) = vbOk Then
           With Me.RecordsetClone
               .FindFirst "[SerialNumber] = '" & Me.txtSerNo & "'"
               If Not .NoMatch Then
                   Me.Bookmark = .Bookmark
               End If
           End With
       Else
           Me.txtSerNo.Undo
       End If
   End If
End Sub

Signature

Dave Hargis, Microsoft Access MVP

> I have a form that I enter serial numbers in.  I was wondering if there is a
> way to tell if a number has already been entered.  I would like something
[quoted text clipped - 3 lines]
> advance.
> Jane
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.