ADODC by date problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • opie
    New Member
    • Nov 2007
    • 15

    #1

    ADODC by date problem

    I am trying to move through records in a table using the ADODC tool. But I want to move through those records that occur on a specigic date, a date that was selected on a calandar using another form.

    I was using the following code and I cannot get it to work.

    Any Ideas?

    Thank You in advance.


    RecordSource = SELECT * FROM tblLog WHERE EventDate = #Forms!EditEntr yByDate!calLog#
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by opie
    I am trying to move through records in a table using the ADODC tool. But I want to move through those records that occur on a specigic date, a date that was selected on a calandar using another form.

    I was using the following code and I cannot get it to work.

    Any Ideas?

    Thank You in advance.


    RecordSource = SELECT * FROM tblLog WHERE EventDate = #Forms!EditEntr yByDate!calLog#
    Hello, opie!

    I got just the thing. I urge you to search through the pages under adodc1...If it means looking through specific records, I can show you how to do this in DAO or you can look it up yourself here:

    [CODE=VB]

    Dim myDatabase As Database
    Dim myRecord As Recordset
    Set myDatabase = OpenDatabase("C :\DataMining\Da ta_Central.mdb" )
    Set myRecord = myDatabase.Open Recordset("SELE CT * FROM YourTable WHERE UserID='" & Text1(0).Text & "'")

    [/CODE]

    You can turn UserID into the date field to search for specific date.

    Please look for that post for added support. Adodc1 helps you page through the data... I thought to have read ADO is not that far off, you also fetch results here or Google on it; perhaps something of a difference between the two is posted.

    Good luck:-)

    Dököll

    Comment

    • opie
      New Member
      • Nov 2007
      • 15

      #3
      I have looked through the post several times. I cannot get this to work after about a week of working at it off and on.

      It work fine when I insert the the exact date as the recordSource as shown below.

      Code:
      SELECT * FROM tblLog WHERE EventDate = #12/7/2007#
      But when I try to refer it to a form that is still in memory (I have not unloaded the form) it gives me a syntax error. Now I am using MS Access Syntax so maybe that is the problem, but in this instance I figured it would be the same and I am unable to find the proper syntax.

      Code:
      SELECT * FROM tblLog WHERE EventDate = #forms!EditEntryByDate!calLog#

      Comment

      • daniel aristidou
        Contributor
        • Aug 2007
        • 494

        #4
        If your getting a data type error or the wrong records.
        Try using
        The CDate This converts the the record feild and criteria into the same date format.
        Code:
        WHERE Cdate(EventDate) = cdate(forms!EditEntryByDate!calLog)
        Ps im not too sure about the " ' " that are needed.
        i usually just use trial error.
        When i first got this problem took me ages to find solution :)

        Hope this helps you......... if not it may others.

        Holiday Greetings
        Daniel

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Originally posted by opie
          I have looked through the post several times. I cannot get this to work after about a week of working at it off and on.

          It work fine when I insert the the exact date as the recordSource as shown below.

          Code:
          SELECT * FROM tblLog WHERE EventDate = #12/7/2007#
          But when I try to refer it to a form that is still in memory (I have not unloaded the form) it gives me a syntax error. Now I am using MS Access Syntax so maybe that is the problem, but in this instance I figured it would be the same and I am unable to find the proper syntax.

          Code:
          SELECT * FROM tblLog WHERE EventDate = #forms!EditEntryByDate!calLog#
          Bummer, let's try to muscle through it then togheter, how's that for a deal?

          Are you saying you did not find the post mentioned?

          If you click on my handle and go through, has to be further in the pages, I'll race ya:-)

          I am having look by the way because I must fire my notebook to get a real look...

          Also there are bits of information you can use from others that have posted.
          I'll attempt to type it up an try it.

          In a bit!
          Last edited by Dököll; Dec 28 '07, 12:40 AM. Reason: added remark...

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            #6
            Beat ya:-)

            Alright, this is one of two links, my apologies I thought I had it all in one post...

            I must fetch another old post:-)




            Got it. I decided to just strip it for spare parts, it is a rather large post...

            [CODE=VB]
            Private Sub cmdAdd_Click()

            Dim my_database As Database

            Set my_database = OpenDatabase("C :\Yoda1.mdb")

            my_database.Exe cute "insert into Yoda1.Yoda(User ID, Name, Address, Phone, Email) Values('" & Text1.Text & "','" & Text2.Text & "' , '" & Text3.Text & "' , '" & Text4.Text & "','" & Text5.Text & "')"
            my_database.Clo se '

            Text1.Text=""
            Text2.Text=""
            Text3.Text=""
            Text4.Text=""
            Text5.Text=""

            End Sub
            [/CODE]

            You'll need to reference DAO 3.6, I think.

            So if you have a date field in your access database, you should be able to load into VB using this code.

            Try it, and good luck:-)
            Last edited by Dököll; Dec 28 '07, 01:16 AM. Reason: code found, yeepee!

            Comment

            • Dököll
              Recognized Expert Top Contributor
              • Nov 2006
              • 2379

              #7
              Originally posted by Dököll
              Beat ya:-)

              Alright, this is one of two links, my apologies I thought I had it all in one post...

              I must fetch another old post:-)




              Got it. I decided to just strip it for spare parts, it is a rather large post...

              [CODE=VB]
              Private Sub cmdAdd_Click()

              Dim my_database As Database

              Set my_database = OpenDatabase("C :\Yoda1.mdb")

              my_database.Exe cute "insert into Yoda1.Yoda(User ID, Name, Address, Phone, Email) Values('" & Text1.Text & "','" & Text2.Text & "' , '" & Text3.Text & "' , '" & Text4.Text & "','" & Text5.Text & "')"
              my_database.Clo se '

              Text1.Text=""
              Text2.Text=""
              Text3.Text=""
              Text4.Text=""
              Text5.Text=""

              End Sub
              [/CODE]

              You'll need to reference DAO 3.6, I think.

              So if you have a date field in your access database, you should be able to load into VB using this code.

              Try it, and good luck:-)
              Sorry wrong code, you need SELECT FROM, I have been doing this lately, fogetting stuff:-)

              [CODE=VB]

              'this is searching for existing data in your access

              Private Sub Seek_Click() 'this is your button
              Dim my_database As Database 'dimension database as database
              Dim my_record As Recordset 'dimension recordset as recordset

              Set my_database = OpenDatabase("C :\DataMining\Yo da.mdb")

              'You can change above path/folder name to location of your own access
              'database

              'Going forward, above function will open your database
              'Make sure your databse is closed

              Set my_record = my_database.Ope nRecordset("sel ect * from Yodamania where UserID like '" & Text1.Text & "'") ' this is used to search by user id

              Do While Not my_record.EOF

              'this function will keep searching for fields matching each textbox

              Text1.Text = my_record.Field s("UserID")
              Text2.Text = my_record.Field s("Name")
              Text3.Text = my_record.Field s("Address")
              Text4.Text = my_record.Field s("Phone")
              Text5.Text = my_record.Field s("Email")

              my_record.MoveN ext
              Loop
              my_database.Clo se
              End Sub

              [/CODE]

              Remember to use DAO, you will get an error without a reference; I am sure you know that, just saying it before I forget:-)

              Also, rest assure your adodc1 control will work just fine with DAO...

              In a bit!
              Last edited by Dököll; Dec 28 '07, 01:26 AM. Reason: updated comment, added remark...

              Comment

              Working...