473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Vb + Msaccess

Hi I am trying to develop a Database application with VB6 and MS ACCESS.

Sub Main()
' First we initialize paths for all needed files
gstrDBPath = "c:\dvp\PBG"
gOrderDetailsPath = "c:\dvp\PBG\OrderDetail.txt"
'gOrderDetailsPath = "G:\order.txt"

'Load frmImportData
'frmImportData.Show
Set gdbFML = OpenDatabase(gstrDBPath & "\WVCommon.mdb")
frmImportData.Show

Dim frm As Form
' Loop through all open forms and close them
For Each frm In Forms
Unload frm
Next frm
End Sub

This is the code in my "module".

Now when I uncomment
'Load frmImportData
I get a Runtime error 91

at the statement in the form where I am using the following line

Set rs = gdbFML.OpenRecordset(strSQL)

I went thru the forms here and realized I may not have added the needed reference but the only problem is I dont know which reference is needed.

Could somene plz help me out with this plz.
Aug 22 '07 #1
9 1538
Heggr
18
Hi I am trying to develop a Database application with VB6 and MS ACCESS.

Sub Main()
' First we initialize paths for all needed files
gstrDBPath = "c:\dvp\PBG"
gOrderDetailsPath = "c:\dvp\PBG\OrderDetail.txt"
'gOrderDetailsPath = "G:\order.txt"

'Load frmImportData
'frmImportData.Show
Set gdbFML = OpenDatabase(gstrDBPath & "\WVCommon.mdb")
frmImportData.Show

Dim frm As Form
' Loop through all open forms and close them
For Each frm In Forms
Unload frm
Next frm
End Sub

This is the code in my "module".

Now when I uncomment
'Load frmImportData
I get a Runtime error 91

at the statement in the form where I am using the following line

Set rs = gdbFML.OpenRecordset(strSQL)

I went thru the forms here and realized I may not have added the needed reference but the only problem is I dont know which reference is needed.

Could somene plz help me out with this plz.
When I do this I set a TYPE in my OpenRecordset statement. Try something like this: Set rs = gdbFML.OpenRecordset(strSQL, dbOpenDynaset)

Heggr
Aug 22 '07 #2
Heggr
18
I left out the reference you were looking for also. You will want to add a reference to Microsoft DAO 3.6 Object Library. Your version may be different than 3.6 but everything else should say the same.
Aug 22 '07 #3
I left out the reference you were looking for also. You will want to add a reference to Microsoft DAO 3.6 Object Library. Your version may be different than 3.6 but everything else should say the same.
Hey thanx a lot .... I have added the DAO Library, but still get the same error when I try to load the form. Please tell me wht I am doing wrong.
Aug 23 '07 #4
Heggr
18
If the error is happening on the same line still I would make sure you have declared the rs variable as DAO.Recordset. You may also need to declare gdbFML as a DAO.Database. I find it extremely helpful to use Option Explicit in my code to force me to declare all my variables.

If the error is happening else where in the form I would need additional information to be able to offer any assistance.
Aug 23 '07 #5
Man none of those things helped check the code


Sub Load_Tables(tabname As String, filename As String)
Dim response As Integer
Dim temp As Integer

'First get the total number of record in OrderDetail
strSQL = "SELECT Count(*) AS totalordercount FROM OrderDetail;"
Set rs = gdbFML.OpenRecordset(strSQL, dbOpenDynaset)

temp = rs.RecordCount
'MsgBox temp

' If there are records then we ask if we need to overwrite them
If Not rs.EOF Then
totalOrderCount = rs!totalOrderCount
End If

If totalOrderCount <> 0 Then
response = MsgBox("The Table has records, Do you want to delete them", vbInformation + vbYesNo, "Confirmation")
If response = vbYes Then
delete_data ("OrderDetail")
source_data ("OrderDetail")
Else
MsgBox ("The table might have duplicate entries hence the sourcing aborted")
End If
Else
'else there no Orders Found .. just write to table
MsgBox ("No Records Found .... Safely sourcing data")
source_data ("OrderDetail")
End If
End Sub



And my MODULE has the following code

Global gdbFML As DAO.Database
Global rs As DAO.Recordset
Global gstrDBPath As String
Global gOrderDetailsPath As String

Sub Main()
' First we initialize paths for all needed files
gstrDBPath = "c:\dvp\PBG"
gOrderDetailsPath = "c:\XYZ\OrderDetail.txt"

'MsgBox "x"
'Load frmImportData
'frmImportData.Show vbModal
Set gdbFML = OpenDatabase(gstrDBPath & "\WVCommon.mdb")
frmImportData.Show
End Sub



Now this project has just 1 form which has that code.

Now the project starts from the main() in the module

When i run the project I get

runtime error 91

and the when I hot debug, it comes to line

"Set rs = gdbFML.OpenRecordset(strSQL, dbOpenDynaset)"

and stops.
Aug 30 '07 #6
Heggr
18
In your original post you stated
Now when I uncomment
'Load frmImportData
I get a Runtime error 91


If you are still uncommenting this line and trying to run the code then your problem is that you are setting your gdbFML variable after you are loading the form. If you move the Set gdbFML line to before the Load frmImportData you should be OK.

If you are leaving the Load frmImportData commented out then I am not seeing why you are having the problem. Setting gdbFML to the database before showing the form is the correct way to do it. By doing a frmImportData.Show should both load and show the form on the screen.
Aug 30 '07 #7
Thanx a lot ....
The error is gone

But the form is not getting displayed on the screen can u think of any reason why tis is happening????
Aug 31 '07 #8
Thanx a lot for all ur help ... but I kinda solved the problem
Aug 31 '07 #9
The problem is at the sql statement.Driver donot allow diredt sql quries like this .Remove Count(*).The code will work
Aug 31 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brad Burke | last post by:
From a windows .Net app, I need to 1) check if MSAccess is already open to a certain Access application. If so, then open a form and find a certain record. 2) If not open, then open MSAccess and...
15
by: (Pete Cresswell) | last post by:
I've got a .BAT file that I use for executing various MS Access apps that I wrote way back in the days of 2.0. It's evolved over time, but it still contains a number of possible paths to...
0
by: Richard Beacroft | last post by:
Trying to write a C# Windows App to export all objects and content from 2 MSAccess 97 databases for comparison analysis. very little documentation found. Have managed to instantiate MSAccess,...
4
by: Annick Van Hoof | last post by:
Hi, I'm having my ASP.NET application hosted at a Windows 2003 server (IIS6). This works almost all the time (I have uptimes of 100% on most days), but then all of a sudden a few days in a row I...
0
by: MLH | last post by:
I've been unable to determine the correct setting to force a copy of msaccess.exe to be written to target disk during runtime installation process. It may be that the runtime installation...
2
by: reidarT | last post by:
I am making an installation program for an Access application. The application is run on both Office 2000, 2002, 2003 and soon 2007 versions of Office, When I install the application I need a...
1
by: rolandsk | last post by:
I need help to schedule a MsAccess procedure I want the procedure to run in backgrund and not the MsAccess file to be open during the time when the procedure runs. The procedure in MsAccess picks...
1
by: vikramrawal | last post by:
hi, I am using C# with MSAccess XP. I need to insert bulk of records around 10000 in MSAccess. So obviously if I inserts each record individually then it will take lot of time. By using...
0
nehashri
by: nehashri | last post by:
hi, I need one help regarding Asp with MsAccess database. Problem. ======== i want to retrive stored image from the MSAccess database using asp.
0
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.