Results 1 to 3 of 3

Thread: Data Access Errors

  1. #1

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Data Access Errors

    I am trying to access a database, but get an error. This is the code i am using.

    Form Load
    VB Code:
    1. Private Sub Form_Load()
    2. MyFile = App.Path & "\Copy of Diary.mdb"        
    3. Set MyDatabase = OpenDatabase(MyFile)
    4. End Sub

    Command Button
    VB Code:
    1. SqLtXt = "SELECT Entry.Date, Entry.Subject, Entry.Entry"
    2. SqLtXt = SqLtXt + " From Entry"
    3. SqLtXt = SqLtXt + " WHERE Entry.Date = " & dtpDate.Value
    4.    
    5. Set MySearch = MyDatabase.OpenRecordset(SqLtXt)
    6.  
    7. txtSubject.Text = MySearch!Subject & ""
    8. txtEntry.Text = MySearch!Entry

    What am i doing wrong, the error is...

    "3021, No current record".

    Which isnt true because there is a record called 03/06/2005 in the database.

    Thank you
    ILMV

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Data Access Errors

    SqLtXt = "SELECT Entry.Date, Entry.Subject, Entry.Entry"
    SqLtXt = SqLtXt + " From Entry"
    SqLtXt = SqLtXt + " WHERE Entry.Date = " & "'" & dtpDate.Value & "'"

    Set MySearch = MyDatabase.OpenRecordset(SqLtXt)
    if not mysearch.bof and not mysearch.eof then

    txtSubject.Text = MySearch!Subject & ""
    txtEntry.Text = MySearch!Entry
    else
    endif

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Data Access Errors

    OR, since this is Access... use this:

    SqLtXt = SqLtXt + " WHERE Entry.Date = #" & dtpDate.Value & "#"

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width