|
-
Sep 12th, 2005, 04:16 AM
#1
Thread Starter
Lively Member
[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
-
Sep 12th, 2005, 05:20 AM
#2
Re: Vb & MS Access
 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."
-
Sep 12th, 2005, 09:40 AM
#3
Thread Starter
Lively Member
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
-
Sep 12th, 2005, 09:45 AM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 12th, 2005, 09:45 AM
#5
Re: Vb & MS Access
 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:
Dim sSQL As String
sSQL = "SELECT * FROM table WHERE condition = '" & whatever & "'"
adoRecordsetObject.Open sSQL adoConnectionObject
Where adoRecordsetObject is a preDimmed ADO Recordset and adoConnectionObject is what you used to open your database.
-
Sep 12th, 2005, 09:50 AM
#6
Re: Vb & MS Access
Yes, you can create queries in Access via VB.
VB Code:
Dim sSQL As String
'qryLogAnalysisErrors
sSQL = "CREATE VIEW qryLogAnalysisErrors AS SELECT"
sSQL = sSQL & " Q1.ID,"
sSQL = sSQL & " Q1.DateTime,"
sSQL = sSQL & " Q1.Source,"
sSQL = sSQL & " Q1.Type,"
sSQL = sSQL & " Q1.Computer,"
sSQL = sSQL & " Q1.Message,"
sSQL = sSQL & " Q1.EventID,"
sSQL = sSQL & " Q1.SessionDate"
sSQL = sSQL & " FROM"
sSQL = sSQL & " [" & cboComputer & "_" & cboLogType & "] AS Q1"
If cboLogType = "Application" Or cboLogType = "System" Then
sSQL = sSQL & " WHERE Q1.Type = 'Error'"
Else
sSQL = sSQL & " WHERE Q1.Type = 'Failure'"
End If
sSQL = sSQL & " AND"
sSQL = sSQL & " (((Q1.SessionDate)=#" & dCurrSessDate & "#))"
sSQL = sSQL & " GROUP BY"
sSQL = sSQL & " Q1.ID,"
sSQL = sSQL & " Q1.SessionDate,"
sSQL = sSQL & " Q1.Computer,"
sSQL = sSQL & " Q1.Source,"
sSQL = sSQL & " Q1.Type,"
sSQL = sSQL & " Q1.DateTime,"
sSQL = sSQL & " Q1.EventID,"
sSQL = sSQL & " Q1.Message;"
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 12th, 2005, 10:07 AM
#7
Thread Starter
Lively Member
Re: Vb & MS Access
thanks rob
but it's not working her is my code
VB Code:
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.
-
Sep 12th, 2005, 10:26 AM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 12th, 2005, 10:37 AM
#9
Thread Starter
Lively Member
-
Sep 12th, 2005, 10:45 AM
#10
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|