Results 1 to 22 of 22

Thread: Docmd error

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    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?

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Docmd error

    Which language are you using vb6 or VBA (I guess vb6 but just making sure)?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    yes vb6

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    what do you mean by apt parent object?

    what do i have to write in my code?

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    no one has found a solution??

  9. #9
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Docmd error

    Why are you trying to print information when it doesn't even exist in memory?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    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 .

  11. #11
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    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.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    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"

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Docmd error

    Are you trying to access the file over a network?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  14. #14
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Docmd error

    Where did "Data Source=" come from?

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    yes im accessing the file over a network

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    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

  17. #17
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Docmd error

    Do you need to include the protocol type in the open method?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    i think yes, if not , how shall i open the database?

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    no replies,

    i really need help

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    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.

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    need help plz, i'm still stuck

  22. #22

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    150

    Re: Docmd error

    Plzzzzzz someones help

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