Results 1 to 10 of 10

Thread: [RESOLVED] Vb & MS Access

  1. #1

    Thread Starter
    Lively Member mowafy's Avatar
    Join Date
    Jul 2005
    Posts
    116

    Resolved [RESOLVED] Vb & MS Access

    i have application working on Sql server and Access on the same time
    how can i create view on access from visual basic
    i can make it with Sql server like create view [myview] as (sqlstatment)
    but it dosn't work with access
    please help

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Vb & MS Access

    Quote Originally Posted by mowafy
    i have application working on Sql server and Access on the same time
    how can i create view on access from visual basic
    i can make it with Sql server like create view [myview] as (sqlstatment)
    but it dosn't work with access
    please help

    There is no such thing as a view in MS Access. But Access has an object called a query which is similiar but not the same. You would probably be better off connecting to your databases via ado. Take a look at the links in my signature regarding ado.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3

    Thread Starter
    Lively Member mowafy's Avatar
    Join Date
    Jul 2005
    Posts
    116

    Re: Vb & MS Access

    thanks mark
    i'm connecting to data by using ADO but i don't know how to create that query from vb

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Vb & MS Access

    Moved to Office Development
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Vb & MS Access

    Quote Originally Posted by mowafy
    thanks mark
    i'm connecting to data by using ADO but i don't know how to create that query from vb
    Like this
    VB Code:
    1. Dim sSQL As String
    2. sSQL = "SELECT * FROM  table WHERE condition = '" & whatever & "'"
    3. adoRecordsetObject.Open sSQL adoConnectionObject
    Where adoRecordsetObject is a preDimmed ADO Recordset and adoConnectionObject is what you used to open your database.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Vb & MS Access

    Yes, you can create queries in Access via VB.
    VB Code:
    1. Dim sSQL As String
    2. 'qryLogAnalysisErrors
    3. sSQL = "CREATE VIEW qryLogAnalysisErrors AS SELECT"
    4. sSQL = sSQL & " Q1.ID,"
    5. sSQL = sSQL & " Q1.DateTime,"
    6. sSQL = sSQL & " Q1.Source,"
    7. sSQL = sSQL & " Q1.Type,"
    8. sSQL = sSQL & " Q1.Computer,"
    9. sSQL = sSQL & " Q1.Message,"
    10. sSQL = sSQL & " Q1.EventID,"
    11. sSQL = sSQL & " Q1.SessionDate"
    12. sSQL = sSQL & " FROM"
    13. sSQL = sSQL & " [" & cboComputer & "_" & cboLogType & "] AS Q1"
    14. If cboLogType = "Application" Or cboLogType = "System" Then
    15.     sSQL = sSQL & " WHERE Q1.Type = 'Error'"
    16. Else
    17.     sSQL = sSQL & " WHERE Q1.Type = 'Failure'"
    18. End If
    19. sSQL = sSQL & " AND"
    20. sSQL = sSQL & " (((Q1.SessionDate)=#" & dCurrSessDate & "#))"
    21. sSQL = sSQL & " GROUP BY"
    22. sSQL = sSQL & " Q1.ID,"
    23. sSQL = sSQL & " Q1.SessionDate,"
    24. sSQL = sSQL & " Q1.Computer,"
    25. sSQL = sSQL & " Q1.Source,"
    26. sSQL = sSQL & " Q1.Type,"
    27. sSQL = sSQL & " Q1.DateTime,"
    28. sSQL = sSQL & " Q1.EventID,"
    29. sSQL = sSQL & " Q1.Message;"
    30. goEnv.Cnn.Execute sSQL
    Last edited by RobDog888; Sep 12th, 2005 at 09:54 AM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Lively Member mowafy's Avatar
    Join Date
    Jul 2005
    Posts
    116

    Re: Vb & MS Access

    thanks rob
    but it's not working her is my code
    VB Code:
    1. create view ItemsSales as  SELECT SUM(Transact.TransQuantity *  (Transact.TransUnitPriceKD - Transact.trnDiscAmount)) AS TotSale, SUM(Transact.TransQuantity) AS TotQty,  Transact.TransItemCode, SUM(Transact.TrnTotCost) AS TotCost,  Transact.TrnstrNo FROM Invoice INNER JOIN  Transact ON Invoice.InvCode = Transact.TransCode AND  Invoice.InvNo = Transact.TransNo  Where Transact.TransCode = 10  )
    its give me ann error " Excepected token : select "
    Last edited by RobDog888; Sep 12th, 2005 at 10:27 AM.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Vb & MS Access

    The easiest way to debug these is to go into Access and create a new query of just the SELECT part. Then once its running correctly you can bring it back into vb with some minor mods. I see your missing a GROUP BY clause since your not performing an aggregraste function on all fields included in the select list.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Lively Member mowafy's Avatar
    Join Date
    Jul 2005
    Posts
    116

    Re: Vb & MS Access

    thanks all
    i resolved

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] Vb & MS Access

    What was the offending issue?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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