Results 1 to 11 of 11
  1. #1
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39

    Question how to hard code a value to a field?

    how can I hard code a value here? So for every row returned, it will have this value. I have a field called description. I want to put a specific value here so every line will contain that word.



    How do i add that in design view?



    Click image for larger version. 

Name:	Capture.JPG 
Views:	8 
Size:	53.3 KB 
ID:	20895

  2. #2
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Is this just to display the value for a report?

    Are you actually wanting the value in the table?

    Are you wanting to have the default of this field to be this certain value?

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    From your picture, it looks like this field ("GTR-DESCRIPTION") is already a calculated field, it is just set up to return a blank.
    Just place whatever you want to be returned between the two single quotes, i.e.

    Code:
    GTR-DESCRIPTION:'My Text Here'

  4. #4
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39
    When I run the report, I want every row to contain that specific value. Example, in that field I want it to say ARGL, so when I run the report, every row should have ARGL.

  5. #5
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39
    JoeM, when I do that, i get "the expression you entered contains invalid syntax."

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If not single quotes, try double-quotes:
    Code:
    GTR-DESCRIPTION:'ARGL'
    or
    Code:
    GTR-DESCRIPTION:"ARGL"
    You are doing all this in the underlying query itself (and not trying trying to do it directly on the Report, right?)

  7. #7
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39
    single quote worked! thank you, I am doing it in design view.

    how do I mark this topic solved?

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    how do I mark this topic solved?
    See: https://www.accessforums.net/forum-s...lved-1828.html

  9. #9
    eeps24 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2015
    Posts
    39
    sorry guys, im back again. So when I type 'argl' (in design view) and run my query everything is blank. When I remove 'argl' then my query works. any thoughts?Click image for larger version. 

Name:	Capture.JPG 
Views:	8 
Size:	48.6 KB 
ID:	20987

  10. #10
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Look at what you have in the Field row:
    Code:
    GTR-DESCRIPTION:''
    That means that you are hard-coding EVERY record to return blank for this calculated field.

    Then you are entering 'argl' in the Criteria row.
    That is telling Access to return every record where the field is equal to 'argl'. Since you set everything equal to blank, nothing meets that criteria and no records are returned.

    If you are trying to hard-code the field to 'argl', you need to put this on the Field row, just like we showed up in post #6.
    Code:
    GTR-DESCRIPTION:'argl'
    There shouldn't be a need to put anything on the Criteria row, as you aren't trying to limit any records selected here, but just trying to hard-code a value.

  11. #11
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Quote Originally Posted by eeps24 View Post
    sorry guys, im back again. So when I type 'argl' (in design view) and run my query everything is blank. When I remove 'argl' then my query works. any thoughts?Click image for larger version. 

Name:	Capture.JPG 
Views:	8 
Size:	48.6 KB 
ID:	20987

    Refer back to post #3.

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

Similar Threads

  1. Create Query Object vs Hard Code
    By sstiebinger in forum Queries
    Replies: 5
    Last Post: 05-13-2015, 08:37 AM
  2. is this possible & is this hard to do Please help
    By Debbie_P in forum Database Design
    Replies: 4
    Last Post: 02-10-2015, 08:21 AM
  3. Hard to explain how to do this?
    By flemingjo in forum Forms
    Replies: 1
    Last Post: 08-29-2014, 06:03 AM
  4. Replies: 1
    Last Post: 05-04-2013, 12:19 PM
  5. Hard Question
    By chivo123 in forum Access
    Replies: 4
    Last Post: 01-20-2012, 10:44 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