Results 1 to 6 of 6
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    Exporting a query\VBA (Im not sure which to use) to csv

    Hi Guys,
    As the title suggests Im at a bit of a loss as to where or how I achieve my goal. What I have is a table which consists of Activity, Project, hours (which can be negative), description, code and username.
    Those entries within that table represent a number within a different table. How do I produce a query which will output the corresponding column data and also join two fields as well. A more descriptive explanation:



    I start with Activity, project, hours, description, code and username and I would like
    AB if the hours is positive AD if the hours are negative, PP-XXX - where PP is the corresponding field of Project entered and XXX is the corresponding field of the activity (outputting a joined result), code which is in the table as its entered, and also set a standard entery for 4 other fields.

    Im guessing this probably doesnt make too much sense so if I need to elaborate a little please say so. Its difficult to pertray what I mean.
    Thanks in advance

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    I gather that you want two different columns for hours, one positive and the other negative. That can be handled with calculated fields.
    From your description, query design should be able to handle the setup. From there, you could get the SQL if you need it.
    How about trying the query design and post the resulting SQL if you get stuck.

  3. #3
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    Kind of, I have an hours field which users enter into. This has a switch to convert the number from a positive to a negative. If the number is positive then I would like to output AB and if negative then AD.

    I am trying the query design to get things going - I dont suppose you know why its duplicating the results? I have 3 columns repeating themselves whilst there are only 2 entires in the table. My the sql is below if that helps?

    Code:
    SELECT TimesheetTable.sUser, TimesheetTable.[Task Date], TimesheetTable.Description, TimesheetTable.sCostCode, TimesheetTable.Hours
    FROM TimesheetTable, ProjectsTable;

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Your SQL doesn't show a join, which you previously mentioned, nor

    Quote Originally Posted by shabbaranks View Post
    Kind of, I have an hours field which users enter into. This has a switch to convert the number from a positive to a negative. If the number is positive then I would like to output AB and if negative then AD.

    I am trying the query design to get things going - I dont suppose you know why its duplicating the results? I have 3 columns repeating themselves whilst there are only 2 entires in the table. My the sql is below if that helps?

    Code:
    SELECT TimesheetTable.sUser, TimesheetTable.[Task Date], TimesheetTable.Description, TimesheetTable.sCostCode, TimesheetTable.Hours
    FROM TimesheetTable, ProjectsTable;
    any calculation for the positive/ negative numbers.
    The duplicates may be the result of the lack of join information. I expected that you would show some fields being selected from each of the tables, and an equality/non-equality statement (a WHERE clause ) specifying the join.
    Are there any established relationships between the tables?

  5. #5
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162
    There arent any relationships between the tables, I thought I needed a relationship but I read somewhere that you dont as you can do the reporting by joining? Not knowing a great deal about this I wasnt sure?

    The positive negative numbers I didnt have a clue how to setup but thought I would attempt getting somewhere first?

    Thanks

  6. #6
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    If one of the tables has a key from the other table, you should define the table relationships IMHO.
    Without that and with no join info, I'm not surprised that you are getting duplicates.
    As to the positve/negative numbers, I can't tell whether that should be part of the query or should be addressed in a form or....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query contents are deleted after exporting the query results
    By alfcee in forum Import/Export Data
    Replies: 6
    Last Post: 11-13-2012, 09:35 AM
  2. Exporting a Query to Excel
    By tcheck in forum Access
    Replies: 3
    Last Post: 07-22-2011, 05:00 PM
  3. Query Exporting to Excel
    By Coffee in forum Queries
    Replies: 2
    Last Post: 07-18-2011, 07:42 AM
  4. Exporting Query to Excel
    By jvera524 in forum Import/Export Data
    Replies: 0
    Last Post: 12-06-2010, 09:16 AM
  5. Exporting a query to HTML
    By Remster in forum Access
    Replies: 8
    Last Post: 09-10-2010, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums