• Creating a form from a query make in SQL View (2002 SP2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Creating a form from a query make in SQL View (2002 SP2)

    Author
    Topic
    #400597

    My office is getting ready to upgrade our document management system from Hummingbird’s Docs Open to DM5. On occasion, I need access to the document where it lives on the server (and not just through the DMS’s interface). Our new DMS has completely locked our ability to see a document’s real path. I have a query created in SQL view that will give me the path to the document, but I would like a way to automate it a bit more.
    [indent]


    SELECT P.DOCNUMBER,V.VERSION,V.VERSION_LABEL,P.DOCSERVER_LOC + P.PATH+C.PATH

    FROM DOCSADM.PROFILE P,DOCSADM.COMPONENTS C,DOCSADM.VERSIONS V Where P.DocNumber = C.DocNumber AND P.DocNumber = V.DocNumber AND C.Version_ID = V.Version_ID AND P.DocNumber = 600000


    [/indent]
    Currently, I have to go into the query, switch to SQL view, manually change the document number (the 600000 at the end), then save to see my path. I was wanting to set up a form that I could type in the document number and it would automatically do all the background stuff and display my path for me. Is there a way to do this?

    Thanks,
    Becky

    Viewing 1 reply thread
    Author
    Replies
    • #782556

      A very simple solution is to replace 600000 by [Enter Document Number]. The user will be prompted with the text between the square brackets.
      Your idea of using a form is more user-friendly. Say that you have a form frmDocPath bound to the query with an unbound text box txtDocNumber. You can refer to this text box by replacing the 600000 by

      [Forms]![frmDocPath]![txtDocNumber]

      You would have to requery the form when the user has entered something in the text box.

      An alternative is to leave the criteria out, and to use the Combo Box Wizard to put a combo box on the form that searches for the document number – make sure that the Wizard button on the Control Toolbox is “on” before you place the combo box.

      • #783493

        I tried doing exactly what you said, but I don’t get a prompt. I only get the error message below. I tried just removing the 60000 (everything after the =), but I got another error similar to the attached.

        Did I do something wrong?

        Thanks,
        Becky

        • #783541

          Where are you trying to create this query? If you create it in an Access mdb with linked SQL Server tables, it should work. If you are using an ADP or trying to create the query in SQL Server, it definitely won’t, since SQL Server knows nothing whatsoever about Access forms and T-SQL doesn’t handle parameters like that.

        • #783542

          Where are you trying to create this query? If you create it in an Access mdb with linked SQL Server tables, it should work. If you are using an ADP or trying to create the query in SQL Server, it definitely won’t, since SQL Server knows nothing whatsoever about Access forms and T-SQL doesn’t handle parameters like that.

        • #783543

          I hadn’t realized that this was an ODBC connection to a SQL Server database. Unknown territory for me, so I hope somebody else takes over. Sorry about the confusion.

        • #783544

          I hadn’t realized that this was an ODBC connection to a SQL Server database. Unknown territory for me, so I hope somebody else takes over. Sorry about the confusion.

        • #783695

          The error message you got suggests there was something wrong with the syntax of the query, but you should also be able to simply use a parameter query – we do it all the time with ODBC attached SQL Server tables. Are you familiar with parameter queries?

          • #783898

            Unfortunately, I’m not at all familiar with parameter queries. My boss (the system admin) and I are trying to figure this out with absolutely no knowledge of what we’re actually doing. woops We’ve worked with queries and forms and all kinds of Access stuff, but this is our first time trying to talk to anything outside of Access.

            Thanks,
            Becky

            • #783957

              To do a parameter query, you put a text string in the query grid for the Criteria row that is surrounded by square brackets, for example [Enter the Date you wish to use in your query], and when you run the query you will get a message box with that text string and a text box to supply the date value. I would suggest you find an introductory book on Access if you are starting pretty much from scratch – one of the Step-byStep books or Dummies books or something like that. In the meantime, you might find some of the info you need at one of the websites that offer online tutorials – http://databases.about.com/cs/tutorials/%5B/url%5D is one such site, and they have a queries tutorial.

              Updated to add a link to a Parameter Query tutorial:
              Here’s a link to a tutorial on Parameter Queries.

            • #784165

              Silly me, I forgot that my husband is an Access & SQL database programmer! bagged I sent the stuff over to him, and he fixed everything right up. In my original query, he removed the “AND P.DocNumber = 600000” section and created a second query (a regular access one, this time) that linked to a field in a new empty table he created. The table has a field named “docnumber” just like the the SQL database. The form he created lets you add an entry to the new table, then immediately run the query. It takes a few seconds to run, but it gives us exactly what we needed.

              Thanks to all for the help!
              Becky

            • #784166

              Silly me, I forgot that my husband is an Access & SQL database programmer! bagged I sent the stuff over to him, and he fixed everything right up. In my original query, he removed the “AND P.DocNumber = 600000” section and created a second query (a regular access one, this time) that linked to a field in a new empty table he created. The table has a field named “docnumber” just like the the SQL database. The form he created lets you add an entry to the new table, then immediately run the query. It takes a few seconds to run, but it gives us exactly what we needed.

              Thanks to all for the help!
              Becky

            • #783958

              To do a parameter query, you put a text string in the query grid for the Criteria row that is surrounded by square brackets, for example [Enter the Date you wish to use in your query], and when you run the query you will get a message box with that text string and a text box to supply the date value. I would suggest you find an introductory book on Access if you are starting pretty much from scratch – one of the Step-byStep books or Dummies books or something like that. In the meantime, you might find some of the info you need at one of the websites that offer online tutorials – http://databases.about.com/cs/tutorials/%5B/url%5D is one such site, and they have a queries tutorial.

              Updated to add a link to a Parameter Query tutorial:
              Here’s a link to a tutorial on Parameter Queries.

          • #783899

            Unfortunately, I’m not at all familiar with parameter queries. My boss (the system admin) and I are trying to figure this out with absolutely no knowledge of what we’re actually doing. woops We’ve worked with queries and forms and all kinds of Access stuff, but this is our first time trying to talk to anything outside of Access.

            Thanks,
            Becky

        • #783696

          The error message you got suggests there was something wrong with the syntax of the query, but you should also be able to simply use a parameter query – we do it all the time with ODBC attached SQL Server tables. Are you familiar with parameter queries?

      • #783494

        I tried doing exactly what you said, but I don’t get a prompt. I only get the error message below. I tried just removing the 60000 (everything after the =), but I got another error similar to the attached.

        Did I do something wrong?

        Thanks,
        Becky

    • #782557

      A very simple solution is to replace 600000 by [Enter Document Number]. The user will be prompted with the text between the square brackets.
      Your idea of using a form is more user-friendly. Say that you have a form frmDocPath bound to the query with an unbound text box txtDocNumber. You can refer to this text box by replacing the 600000 by

      [Forms]![frmDocPath]![txtDocNumber]

      You would have to requery the form when the user has entered something in the text box.

      An alternative is to leave the criteria out, and to use the Combo Box Wizard to put a combo box on the form that searches for the document number – make sure that the Wizard button on the Control Toolbox is “on” before you place the combo box.

    Viewing 1 reply thread
    Reply To: Creating a form from a query make in SQL View (2002 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: