make table query specifics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vegak18
    New Member
    • Aug 2007
    • 9

    make table query specifics

    Dear Experts,

    I was was wondering if there was some way to specify output properties of a make table query. Specifically, I am haivng a problem with numbers being specified as text. while I realize I can go in and change the table properties after the table has been created, I create and replace this table quite often so that would become a laborious prcess. Is there some way I can make the query specify that for me. I am using access 2003 and the VBA script of the make talbe query is as follows:
    [CODE=sql]
    SELECT Accounts.Accoun tNumber, Accounts.Accoun tName, Section1Budget. budgetedAmount, NZ([Section 1 Reappropriation s]![budgetedAmount],0) AS Reappropriation s, NZ(NZ([Section1Budget]![budgetedAmount])+NZ([Section 1 Reappropriation s]![budgetedAmount]),0) AS [current appropriations], NZ([section1directP ayVouchers]![SumOfAmount])+ NZ([Section1SPO]![SumOfAmount])+ NZ([Section1Requsit ions]![SumOfAmount]) AS Encumbrances, NZ([current appropriations]-[Encumbrances],0) AS [budget afterencumbranc es], NZ([appaidsection1]![SumOfAPPaidAmou nt],0) AS APPaid, NZ([current appropriations],0)-NZ([APPaid],0) AS [Expendable Funds] INTO section1report
    FROM Section1Budget RIGHT JOIN (Section1Requsi tions RIGHT JOIN (section1direct PayVouchers RIGHT JOIN ([Section 1 Reappropriation s] RIGHT JOIN (appaidsection1 RIGHT JOIN (Accounts LEFT JOIN Section1SPO ON Accounts.Accoun tNumber = Section1SPO.Acc ountNumber) ON appaidsection1. AccountNumber1 = Accounts.Accoun tNumber) ON [Section 1 Reappropriation s].[Account Number] = Accounts.Accoun tNumber) ON section1directP ayVouchers.Acco unt = Accounts.Accoun tNumber) ON Section1Requsit ions.Account = Accounts.Accoun tNumber) ON Section1Budget.[Account Number] = Accounts.Accoun tNumber;
    [/CODE]
    any help you can give me would be greatly appreciated.

    -Andy
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    Originally posted by vegak18
    Dear Experts,

    I was was wondering if there was some way to specify output properties of a make table query. Specifically, I am haivng a problem with numbers being specified as text. while I realize I can go in and change the table properties after the table has been created, I create and replace this table quite often so that would become a laborious prcess. Is there some way I can make the query specify that for me. I am using access 2003 and the VBA script of the make talbe query is as follows:

    [CODE=sql]SELECT Accounts.Accoun tNumber, Accounts.Accoun tName, Section1Budget. budgetedAmount, NZ([Section 1 Reappropriation s]![budgetedAmount],0) AS Reappropriation s, NZ(NZ([Section1Budget]![budgetedAmount])+NZ([Section 1 Reappropriation s]![budgetedAmount]),0) AS [current appropriations], NZ([section1directP ayVouchers]![SumOfAmount])+ NZ([Section1SPO]![SumOfAmount])+ NZ([Section1Requsit ions]![SumOfAmount]) AS Encumbrances, NZ([current appropriations]-[Encumbrances],0) AS [budget afterencumbranc es], NZ([appaidsection1]![SumOfAPPaidAmou nt],0) AS APPaid, NZ([current appropriations],0)-NZ([APPaid],0) AS [Expendable Funds] INTO section1report
    FROM Section1Budget RIGHT JOIN (Section1Requsi tions RIGHT JOIN (section1direct PayVouchers RIGHT JOIN ([Section 1 Reappropriation s] RIGHT JOIN (appaidsection1 RIGHT JOIN (Accounts LEFT JOIN Section1SPO ON Accounts.Accoun tNumber = Section1SPO.Acc ountNumber) ON appaidsection1. AccountNumber1 = Accounts.Accoun tNumber) ON [Section 1 Reappropriation s].[Account Number] = Accounts.Accoun tNumber) ON section1directP ayVouchers.Acco unt = Accounts.Accoun tNumber) ON Section1Requsit ions.Account = Accounts.Accoun tNumber) ON Section1Budget.[Account Number] = Accounts.Accoun tNumber;[/CODE]

    any help you can give me would be greatly appreciated.

    -Andy
    Field names and data types are inherited from the source table in a make table query...

    Are you saying that this isn't happening, and that instead some number data type fields are being transferred across into text fields? Which specific fields in the sql above is this happening with?

    Regards,
    Scott

    Comment

    • vegak18
      New Member
      • Aug 2007
      • 9

      #3
      Originally posted by Scott Price
      Field names and data types are inherited from the source table in a make table query...

      Are you saying that this isn't happening, and that instead some number data type fields are being transferred across into text fields? Which specific fields in the sql above is this happening with?

      Regards,
      Scott
      It is happening to the appropriations field, reappropriaions field, budget after encumbrances, and APPaid

      Comment

      • vegak18
        New Member
        • Aug 2007
        • 9

        #4
        Originally posted by vegak18
        It is happening to the appropriations field, reappropriaions field, budget after encumbrances, and APPaid
        and yeah... all the tables it works off of are all correct and represent the numbrs as numbers..... but for some reason when it translates into this query it turns the numbers into text fields

        Comment

        • Scott Price
          Recognized Expert Top Contributor
          • Jul 2007
          • 1384

          #5
          Strange... I'm not sure why it's doing it this way, when it should be inheriting the field attributes from your parent table.

          There's no way that I know of to make an SQL make-table query reset the field attributes. To do this programmaticall y you'll need to explore the DAO tabledefs/indexes/fields/attributes collections.

          Regards,
          Scott

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            Firstly you haven't specified the value if Null on many of the nz() functions. I think the default is "". This may be your problem. Try the following:

            [CODE=sql]
            SELECT Accounts.Accoun tNumber, Accounts.Accoun tName, Section1Budget. budgetedAmount, NZ([Section 1 Reappropriation s]![budgetedAmount],0) AS Reappropriation s, NZ(NZ([Section1Budget]![budgetedAmount],0)+NZ([Section 1 Reappropriation s]![budgetedAmount],0) AS [current appropriations], NZ([section1directP ayVouchers]![SumOfAmount],0)+ NZ([Section1SPO]![SumOfAmount],0)+ NZ([Section1Requsit ions]![SumOfAmount],0) AS Encumbrances, NZ([current appropriations]-[Encumbrances]),0) AS [budget afterencumbranc es], NZ([appaidsection1]![SumOfAPPaidAmou nt],0) AS APPaid, NZ([current appropriations],0)-NZ([APPaid],0) AS [Expendable Funds] INTO section1report
            FROM Section1Budget RIGHT JOIN (Section1Requsi tions RIGHT JOIN (section1direct PayVouchers RIGHT JOIN ([Section 1 Reappropriation s] RIGHT JOIN (appaidsection1 RIGHT JOIN (Accounts LEFT JOIN Section1SPO ON Accounts.Accoun tNumber = Section1SPO.Acc ountNumber) ON appaidsection1. AccountNumber1 = Accounts.Accoun tNumber) ON [Section 1 Reappropriation s].[Account Number] = Accounts.Accoun tNumber) ON section1directP ayVouchers.Acco unt = Accounts.Accoun tNumber) ON Section1Requsit ions.Account = Accounts.Accoun tNumber) ON Section1Budget.[Account Number] = Accounts.Accoun tNumber;
            [/CODE]

            If that doesn't work there is a CCur() function you can use around the calculations which should force the appropriate output.

            CCur(NZ([Section 1 Reappropriation s]![budgetedAmount],0)) AS Reappropriation s

            Comment

            Working...