Access 2003

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Access 2003

  1. #1
    Join Date
    Mar 2005

    Access 2003


    I have not worked with MS Access at all before, so I apologize for asking a "simple" question. But this is what I am trying to do:
    I made a form in Access where a user puts in a serial#. The hits a command button "next" which should do the following: open a calrecord table. Find this serial# typed by the user. If not found then this serial# is appended to the table. But if found, then i want to get more info from this record in the table. (The calrecord table has a bunch of fields with a bunch of info in it). I want all this info it found to appear in a text box.

    So far I have:

    Private Sub UF_Next_Click()
    Dim TblCalRec As Recordset
    Dim Cdb As Database
    Dim SNbr As String
    Dim a As String
    Dim intFirst As Integer

    SNbr = UCase(UF_SerN)
    Set Cdb = CurrentDb
    Set TblCalRec = Cdb.OpenRecordset("CalRecord", dbOpenTable)

    intFirst = TblCalRec.RecordCount
    With TblCalRec

    Do While Not .EOF
    If ![Serial #] = SNbr Then
    MsgBox "Found"
    End If
    End With

    end sub

    My questions are:
    Is there a way to make this search go faster? I tried using the "findFirst" function but that kept giving me an error.
    Do i use the bookmark function to find out more info from this record? What is the bext way to do that?

    Thanks a ton. ~svn

  2. #2
    Join Date
    Jun 2004
    Houston area
    Make your recordset look for the ONE record with that serial #.

    (I'm assuming you've guarded against duplicate serial #'s in this database and [Serial #] is text.)

    Like this:
    Private Sub UF_Next_Click()
    Dim TblCalRec As Recordset
    Dim Cdb As Database
    Dim sql as String
    sql = "Select CalRecord.* from CalRecord where CalRecord.[Serial #] = '" & UCase(Uf_SerN) & "';"
    Set Cdb = CurrentDb
    Set TblCalRec = Cdb.OpenRecordset(sql)
    With TblCalRec
      If .Recordcount = 0 then
       ![Serial #]
        msgBox "Found"   
      End If
    End With
    End Sub
    Hope this helps!
    Last edited by Laurel; 01-30-2006 at 02:53 PM.
    A balanced diet is a cookie in each hand.

Similar Threads

  1. Displaying the access key assignments
    By Sunil Menon in forum Web
    Replies: 1
    Last Post: 07-26-2002, 09:00 PM
  2. access vs SQL Server
    By Ray Clough in forum Database
    Replies: 7
    Last Post: 09-06-2001, 02:27 PM
  3. Secure registry for remote access
    By Nathan in forum Enterprise
    Replies: 0
    Last Post: 09-06-2001, 06:18 AM
  4. ..or maybe Access will work after all...
    By David Jones in forum Database
    Replies: 5
    Last Post: 09-02-2001, 03:17 AM
  5. Replies: 0
    Last Post: 11-20-2000, 05:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center