Consulting

Results 1 to 6 of 6

Thread: Solved: Access front end SQL backend recordsets

  1. #1
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399

    Solved: Access front end SQL backend recordsets

    Hey,


    I am in the process of doing some testing to try and move forward on implementing an upscale of our product from a single accdr (not split). To an access front end and SQL 2008 express back end.

    However i have some problems as there is alot of custom code utilizing record sets.

    [VBA]Dim myrs as dao.recordset
    set myrs = currentdb().openrecords("Select * FROM patient")[/VBA]

    What is going to be the best way to do something along these lines now that i have a split SQL back end ?

    Any help is always appreciated
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  2. #2
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399
    Well it looks like i will have to go through the whole system and convert it to using ADO instead of DAO.
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  3. #3
    Quote Originally Posted by Movian
    Hey,


    I am in the process of doing some testing to try and move forward on implementing an upscale of our product from a single accdr (not split). To an access front end and SQL 2008 express back end.

    However i have some problems as there is alot of custom code utilizing record sets.

    [vba]Dim myrs as dao.recordset
    set myrs = currentdb().openrecords("Select * FROM patient")[/vba]
    What is going to be the best way to do something along these lines now that i have a split SQL back end ?

    Any help is always appreciated
    DAO will work with an SQl Server back end.

    Try:
    [vba]Dim myrs as dao.recordset
    set myrs = currentdb().openrecords("Select * FROM patient", dbOpenDynaset)[/vba]

    See: VBA Traps: Working with Recordsets
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  4. #4
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    While you can use the method above to reference the recordset, you're missing out on one of the huge benefits of working with SQL as a backend.

    I'd recommend you start evaluating which of these procedures would be better off written as a stored procedure. Depending on what you're doing with the recordset, you can get a dramatic improvement on performance letting SQL handle your data at the server end.

  5. #5
    VBAX Mentor Movian's Avatar
    Joined
    Aug 2008
    Location
    NC, USA
    Posts
    399
    When using DAO with the additional parameter you specified i get the error

    Runtime error 91

    Object Variable or with block variable not set

    [vba]Dim myrs As DAO.Recordset
    Set myrs = CurrentDb().OpenRecordset("Settings", dbOpenDynaset)[/vba]
    I will look into using stored procedures, however this is a LARGE DB (90 mb without only default table information.)

    This is going to be a long process, however im sure it will be worth it in the end. Also i have one other question,

    I have the new adp file on my machine connected to a DB. How would i go about setting it up so that i can deliver it to a client so that they can connect it to a different SQL express DB ?


    ~Ok having some issues with a stored procedure conversion.
    [VBA]
    SELECT tblLookupValues.Value, tblLookupValues.Order
    FROM tblLookupValues
    WHERE (((tblLookupValues.Form1)=ActiveControlParentFormName()) AND ((tblLookupValues.Control)=ActiveControlName()))
    ORDER BY tblLookupValues.Order;[/VBA]

    its complaining that it doesn't know the function activecontrolparentformname()

    Which of course the server will not as thats an internet access function. How would i get around this.

    I use this to setup user definable dropdown lists. for the whole system based on form name and control name.

    As im not too comfortable with SQL yet am having some minor issues (il get through them). Any help in the mean time is appreciated.
    Last edited by Movian; 07-28-2010 at 10:09 AM.
    "From the ashes of disaster grow the roses of success" - Chitty chitty bang bang

    "I fear not the man who has 10,000 kicks practiced once. I fear the man who has 1 kick practiced 10,000 times" - Bruce Lee

  6. #6
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    You need to pass the value of activecontrolparentformname() as a parameter to the stored query.

    I'd also recommend that you check out a book called "Microsoft Access Developers' Guide to SQL Server" - I found this invaluable when I was trying to wrap my head around the differences in SQL coming from Access.

    We are what we repeatedly do. Excellence, therefore, is not an act but a habit.
    Aristotle

Posting Permissions

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