-
Docmd error
hi,
i have this code for opening a report in access
Code:
Dim strDocName As String
Dim strWhere As String
strDocName = "MyReport"
strWhere = "[serial]=" & Me!txtserial
DoCmd.OpenReport strDocName, acPreview, , strWhere
it is working fine when my database is open , when i close my database and press the print button i get an error msg:
you can't carry out this action at the present time.
and the error at this line :
DoCmd.OpenReport strDocName, acPreview, , strWhere
why when i close my database i get this error?
-
Re: Docmd error
Which language are you using vb6 or VBA (I guess vb6 but just making sure)?
-
Re: Docmd error
-
Re: Docmd error
In that case it is not valid to use DoCmd as you have - it is very likely to cause bugs and errors.
You should always qualify it with an apt parent object, eg:
Code:
MyAccessApplicationVariable.DoCmd.OpenReport strDocName, acPreview, , strWhere
As to the issue you mentioned, I would be very surprised if that command worked without a database being loaded - because the report is part of the database, not a separate file.
-
Re: Docmd error
what do you mean by apt parent object?
what do i have to write in my code?
-
Re: Docmd error
A good example of a parent object within VB6 is that a TextBox goes on a form, so the parent object of the TextBox is the form (so in code you might use: Form2.Text1.Text = "Hello").
DoCmd is not a VB6 object, it is an object that is built in to Access VBA. In order to use it validly, you need to specify the parent. I don't know what the parent is, but I wouldn't be surprised if it was the application - hence the massive hint in my example.
-
Re: Docmd error
i tried writing :
Form3.DoCmd.OpenReport strDocName, acPreview, , strWhere
im getting compile error:
method or data member not found.
when i debug it's showing at
.DoCmd
-
Re: Docmd error
no one has found a solution??
-
Re: Docmd error
Why are you trying to print information when it doesn't even exist in memory?
-
Re: Docmd error
it is existing,
when my database is open it will print the repory
when i close the database it will give me the error .
-
Re: Docmd error
I know you have created the database! However, the information doesn't automatically get put into memory. This is what opening the database does, I suggest you read the Database Development FAQ for more info. I found this thread which looks like it explains what you are trying to do.
-
Re: Docmd error
thankx Nightwalker83
i tried the code in the link u sent but i get an error
MS office access cant open the database because it is missing, or opened exclusively by another user or it's not an ADP.
the error in this line:
Code:
AccessApp.OpenCurrentDatabase "Data Source=\\10.70.34.7\it2\PMEW\PROJECTS\Billing System\revenue\rev system\LoginExample\Users.mdb"
-
Re: Docmd error
Are you trying to access the file over a network?
-
Re: Docmd error
Where did "Data Source=" come from? :confused:
-
Re: Docmd error
yes im accessing the file over a network
-
Re: Docmd error
ok i tried this code now
Code:
Set AccessApp = New Access.Application
AccessApp.OpenCurrentDatabase ("\\10.70.34.7\it2\PMEW\PROJECTS\Billing System\revenue\rev system\LoginExample\Users.mdb")
Dim strDocName As String
Dim strWhere As String
strDocName = "MyReport"
strWhere = "[serial]=" & Me!txtserial
AccessApp.DoCmd.OpenReport strDocName, acPreview, , strWhere
im not getting error but nothing is opening
-
Re: Docmd error
Do you need to include the protocol type in the open method?
-
Re: Docmd error
i think yes, if not , how shall i open the database?
-
Re: Docmd error
no replies,
i really need help
-
Re: Docmd error
when i put the path :
Code:
AccessApp.OpenCurrentDatabase ("\\10.70.34.7\it2\PMEW\PROJECTS\Billing System\revenue\rev system\LoginExample\Users.mdb")
i dont get error and when i click to open nothing will open
and when i remove the path just put the name of the database :
Code:
AccessApp.OpenCurrentDatabase ("Users")
i get this error :MS office access cant open the database because it is missing, or opened exclusively by another user or it's not an ADP.
-
Re: Docmd error
need help plz, i'm still stuck
-
Re: Docmd error