Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32

    Using AS keyword for changing the name field

    Hi,
    How I can use "AS" in Access. I want to change the name of the field in Combobox.
    For example I'm using in combobox:



    Select [FirstName] as NAME, [LastName], [Address],[Town], [City],[County] from tblStudentInformation

    But after open the form choose NAME in combobox, and Access tells me: Enter parameter...
    How I can rename "FirstName" to NAME, to be used in combobox?

    I attach .mdb file with the problem.

    P.S. I don't want to change the table field name, if this will propose me
    report_sorting_2000.mdbClick image for larger version. 

Name:	parameter.jpg 
Views:	15 
Size:	163.1 KB 
ID:	12682

    Thanks
    Last edited by rumenrs; 06-11-2013 at 08:30 AM.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You do know that NAME is a Reserved Word in Access, right? http://www.allenbrowne.com/AppIssueBadWord.html#N

  3. #3
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32
    No, I didn't know. But if I choose other word, same situation

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you done a MsgBox on the value *before* trying to use it to see what you have?

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What you posted has a RecordSource of the table and *not* a query.

  6. #6
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32
    I didn't try with MsgBox, All what I want is: ComboBox To have other name, not FirstName, that's why I'm try to use AS

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Create a query and bit your report to that instead of the table.

  8. #8
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32
    Well, I try it with Query, there I'm using like that in the field:
    Test: FirstName

    but same situation...

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Your RowSource Type for the cbo should be a Query, not a List.

  10. #10
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32
    Well... now the combox shows all the name -> I'm still stuck:
    Attached Thumbnails Attached Thumbnails sel2.jpg   sel1.jpg  

  11. #11
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Look at this and see if this is what you are after.

    report_sorting_2000.zip


    Dale

  12. #12
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32
    Well this works but just half of the my problem, when you go to filter, and select Student Name (new name)-> Set Sort order there is again parameter message. How I can remove this message? I don't needed

    P.S. Otherwise I have to change the field name of the table, but this will break all DB
    Attached Thumbnails Attached Thumbnails rep2.jpg  

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Perhaps you could tell us exactly what you are trying to do in plain English.

    If you have this SQL (the query) as the recordsource of your Form/Report
    Code:
    SELECT tblStudentInformation.StudentID
    , tblStudentInformation.FirstName 
    , tblStudentInformation.LastName
    , tblStudentInformation.Address
    , tblStudentInformation.Town
    , tblStudentInformation.City
    , tblStudentInformation.County
    FROM tblStudentInformation;
    You could alter the recordsource with an Order By statement

    The fields are "numbered 1 thru 7".

    ---To SORT by FirstName, you can alter the recordsource with

    Order By 2 (since Firstname is field #2) by default you get ASCending

    --To Sort by County DESCending , you could alter the recordsource with
    Order By 7 DESC;

    When you choose the field to Sort By in your Form, have an After Update event which alters the Recordsource as shown here, then requery the Form. (untested)

    I used the version of the mdb posted by rzw0wr

    Here's his query with my Order By
    SELECT tblStudentInformation.StudentID, tblStudentInformation.FirstName AS [Student Name], tblStudentInformation.LastName, tblStudentInformation.Address, tblStudentInformation.Town, tblStudentInformation.City, tblStudentInformation.County
    FROM tblStudentInformation order by 2;
    Here is the Order by 7 DESC example
    SELECT tblStudentInformation.StudentID, tblStudentInformation.FirstName AS [Student Name], tblStudentInformation.LastName, tblStudentInformation.Address, tblStudentInformation.Town, tblStudentInformation.City, tblStudentInformation.County
    FROM tblStudentInformation order by 7 DESC;
    see the corresponding jpgs for the query results
    Attached Thumbnails Attached Thumbnails OrderBy7Desc.jpg   WithOrderBy2.jpg  

  14. #14
    rumenrs is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Mar 2013
    Posts
    32
    Hi, I don't know why you don't understand me and complain from my English, my English is much better that some guys here... whatever..

    With this:
    SELECT tblStudentInformation.StudentID, tblStudentInformation.FirstName AS [Student Name], tblStudentInformation.LastName, tblStudentInformation.Address, tblStudentInformation.Town, tblStudentInformation.City, tblStudentInformation.County FROM tblStudentInformation order by 2;

    Don't work...

    All what I need is to rename the table filed in the combobox, becase I have big DB and there is one table with field name: "dskm", so this "dskm" is not understandable in the combobox, that's why I want to rename with AS, like SQL query.
    But if I use AS, when I choose this name (renamed name) from the combobox, Access says: Enter Parameter, and this is the problem... the message (like the images above).

    I don't know how to enplane to you, I give also examples...
    In your results, you show me the query, I don't want the query to be filtered, I want to use Filter in the report.


    P.S. If any know how sort report results, using button -> this also will help me

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by rumenrs View Post
    Hi, I don't know why you don't understand me and complain from my English, my English is much better that some guys here... whatever..
    Orange was *not* complaining about your English. He was hoping you could explain it in more simplified terms so even us slow witted people could understand what you needed.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Invalid use of Me keyword
    By tariq1 in forum Programming
    Replies: 3
    Last Post: 08-15-2012, 10:58 AM
  2. SQL Parameters keyword?
    By Buakaw in forum Queries
    Replies: 1
    Last Post: 08-04-2011, 06:53 PM
  3. Replies: 0
    Last Post: 06-03-2011, 04:32 AM
  4. Changin report's fileds with VBA
    By ser01 in forum Reports
    Replies: 4
    Last Post: 04-14-2011, 10:46 AM
  5. Making a keyword search
    By timmy in forum Forms
    Replies: 9
    Last Post: 03-14-2011, 02:57 AM

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