DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: Access 2003

  1. #1
    Join Date
    Mar 2005
    Posts
    96

    Access 2003

    Hi,

    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
    .MoveFirst

    Do While Not .EOF
    If ![Serial #] = SNbr Then
    MsgBox "Found"
    End If
    TblCalRec.MoveNext
    Loop
    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
    Location
    Houston area
    Posts
    557
    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:
    Code:
    
    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
       .AddNew
       ![Serial #]
       .Update
      Else
        msgBox "Found"   
      End If
    End With
    
    End Sub
    
    Hope this helps!
    Laurel
    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

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links