12. (Advanced Programming In Access 2013) Using ADO Recordsets in VBA

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 28

  • @janodi1155
    @janodi1155 4 роки тому +2

    Great video and great series. Thank you! I do have a question about the EOF test before the ADORec.Find. The statement is: If Not ADORec.EOF Then ADORec.MoveFirst. It makes sense that if the cursor is somewhere in the middle of the db, that you would want to put it back to the first record. What about the case where the cursor is equal to EOF? In this case the MoveFirst will not happen. Is that ok? What happens? I'm thinking about just doing an unconditional (no "If Not ADORec.EOF Then" clause) ADORec.MoveFirst before the ADORec.Find. Does that make sense?

  • @mohammadshamshadali4746
    @mohammadshamshadali4746 4 роки тому +1

    Mr Steve plz help me to bound ADO RS to a access form . I try but showing a single row at a time why not showing like datasheet view .

  • @danielvandenbosch8899
    @danielvandenbosch8899 7 років тому +3

    Late binding is always best in my opinion. Otherwise version control from client to client is a pain

  • @Tukayoo1
    @Tukayoo1 6 років тому

    awesome great tut series. how would a save that recordset connection to a public or global variable so that I can call on that connection in my various forms and form controls.

  • @msatishbabu1
    @msatishbabu1 9 років тому

    Hi Steve, This is really good video series on VBA and Database , I have a Query about ADO , If i use do i need to open connection every time by connection string , can i make a global connection to refer all times i execute sql or procedure ?

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  9 років тому +1

      Sathish Naidu Malisetti You can create a public variable and then set it's value when the application opens. Then you can use it anywhere.

  • @elainemartin9724
    @elainemartin9724 8 років тому

    Hi Steve, thank you for the videos.
    I copied exactly the same codes in VBA, yet I could not update and add new records. I guess I didn't run the query well enough in SQL. How about show us the details of the query in SQL? Many thanks.

  • @coaching_engineer
    @coaching_engineer 9 років тому

    Steve, I would like to know what the SQL Server query is. Did you make this in a previous video and I missed it? I would like to run the query you ran to better understand what is going on.

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  9 років тому

      Jaz Isom The query I used is one I created on the fly for this video. You can use whatever query you would like that would return records.

    • @coaching_engineer
      @coaching_engineer 9 років тому

      Ok. I may have to do some review because I don't remember exactly the methodology and keywords of the sql query language.

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  9 років тому

      Yeah I went over the SELECT statement toward the end of the beginner series.

  • @Shallo9
    @Shallo9 8 років тому

    Hi Steve,
    I've got one Question on the above tutorial. When you add a new record to the table in SQL, whats the best way to get back the ID of the recently added record?
    I know I could do Move last and get the ID but thats not fool proof as my project would be distributed application which means there would 10's of users performing the same task and chances are I might get someone else's record ID.
    Any help would be appreciated.
    Many Thanks
    Saleem

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  8 років тому

      +Saleem Md When you add a new record, after you perform the Update method any auto-seeded fields should also populate the value in your recordset. Make sure you perform the update method first though before you try to get the id value.

    • @Shallo9
      @Shallo9 8 років тому

      +Programming I'm confused, why would I perform an Update method when I insert a record with an insert statement?
      Is there anything like Output variable to catch the SCOPE_IDENTITY(). Sorry if I'm insane.

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  8 років тому

      +Saleem Md Are you doing the addition via SQL Insert query or through the recordset?

    • @Shallo9
      @Shallo9 8 років тому

      +Programming Hi Steve,
      I was adding a record via insert statement,. but since I posted my last comment, following are my updates
      - I've written a stored procedure in SQL Server and created a class module (for ex: Customer) with properties and addRecord/updateRecord/readRecord(set) methods in Access Front End
      -Now my form creates a Customer class object, assigns the form data to the Customer object and calls the addRecord method which invokes the Stored Procedure (Which returns me the Auto ID using the SCOPE_IDENTITY()
      JOB DONE
      I hope I'm clear.
      Many thanks for your tutorial & your prompt replies.

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  8 років тому

      Yup, sounds like a pretty good solution.

  • @markwilliams9771
    @markwilliams9771 8 років тому

    If I'm understanding this correctly, with ADO, a select query places the whole record set in the memory of the server; with DAO we retrieve the record set to the memory of the client. But with ADO we can execute commands on one record without placing the whole record set in memory, but not with DAO?

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  8 років тому

      +Mark Williams No, both use memory on your local system. They just have different programming in how they connect and thus some of the options they make available.

    • @StopSocialismUSA
      @StopSocialismUSA 5 років тому

      Mark Williams ado record sources are native to the server. So they are faster

  • @mgmglwin4902
    @mgmglwin4902 9 років тому

    Hello Steve, i'm study very well about your lesson, i'm not a coder or programming, just self study a few week about access, i know little about coding. i have beginner knowladge of C++,HTML,CSS,Javascrip..
    now i got a block at here, i don't know how to solve it. Could you give me some advice. Thankyou very much.
    my Block is : when i run "ADOTEST" in Immediate.. it happen
    "
    compile error: expected variable or procedure, not module access
    "
    Public Sub ADOtest()
    Dim ADOConn As New ADODB.Connection
    Dim ADORec As New ADODB.Recordset

    ' On Error Resume Next
    ADOConn.ConnectionString = "Driver={SQL Server};Server=MaoLong-Pc\SQLEXPRESS;Database=North;Trusted_Connection=Yes;"
    ADOConn.Open
    Do While ADOConn.State 1
    DoEvents
    If ADOConn.State = 0 Then Exit Sub
    Loop
    ' Set ADORec.ActiveConnection = ADOConn
    ' ADORec.LockType = adLockOptimistic
    ' ADORec.Source = "SELECT Company From Customers"
    ' ADORec.Open
    ' If Not ADORec.EOF Then ADORec.MoveFirst
    ' ADORec.Find "Company = 'Conpany CC'", , adSearchForward, 1
    '
    ' If Not ADORec.EOF Then
    ' ADORec("Company") = "Company DD"
    ' ADORec.Update
    ' End If
    '
    ' If Not ADORec.EOF Then ADORec.MoveFirst
    ' Do Until ADORec.EOF
    ' Debug.Print ADORec("Company")
    ' ADORec.MoveNext
    ' Loop
    End Sub
    _____
    My database is "North" is correct. i also try with MaoLong-Pc isn't connect. i put it MaoLong-PC\SQLEXPRESS will be work well. but it happen compile error.

    • @ProgrammingMadeEZ
      @ProgrammingMadeEZ  9 років тому

      +Mg mglwin what line does it error on?

    • @mgmglwin4902
      @mgmglwin4902 9 років тому

      its not like error in code, it pop up a window say:" compile error: expected variable or procedure, not module access ".
      i don't know. sorry for about that. i'm not a really programmer. so i don't know it is code error.. or other... :)

    • @mgmglwin4902
      @mgmglwin4902 9 років тому

      Last Night... i dont type and enter "ADOtest" in Immediate window,the pop up will not showup. i just test with F8 or F5 .the error window are not show up and the exchange data are updated and add new date to SQL. that error pop up is still happening, but the data will be change at SQL, so i'm keep go the Lesson,now.
      Thankyou for Reply.
      and Your Lesson is very easy to Learning.
      and Thank a Lot for everythings.

    • @mgmglwin4902
      @mgmglwin4902 9 років тому

      sorry for my English