Results 1 to 3 of 3
  1. #1
    dude19 is offline Novice
    Windows XP Access 97
    Join Date
    Jun 2011
    Posts
    1

    Input Value based on another textbox value

    I have a report that I am trying to simplify and am running access 97
    There is a qry to pull the type of material and is set by the control source.

    Now I want another textbox (textbox2)to fill in a value on my report based on the type

    So if Type A then value = 7
    Type B then value = 8
    etc......



    If qrytype = "A" Then
    textbox2.value = "7"
    Else
    If qrytype = "B" Then
    textbox2.value = "8" etc,,,

    ^that is what I tried and it never showed a value, I am not sure of the order of how things are run programming wise. I searched around and found after update but that seems like it is used for later versions of access?

    any help?

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    The issue is that you aren't referencing the form. Use Me.ControlName if the control is on the same form or Forms!formName.ControlName if on a different form. Also, no need for .Value as it is implied in vba. Me.txtbox and Me.txtbox.value are the same thing. Also, I prefer a switch statement (Select Case) instead of imbedded IF statements.

    select case Me.qrytype
    case "A"
    me.txtbox2 = 7
    Case "B"
    me.txtbox2 = 8
    ...
    End Select

  3. #3
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254

    dude19 -

    If the report is based upon a query, and that query contains the field [Type], you could just add a calculated field to the underlying query and then, pull that control to the report.

    You could try something like this:

    xValue: IIF([Type]="A",7,IIF([Type]="B",8,0))

    All the best,

    Jim

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

Similar Threads

  1. Replies: 5
    Last Post: 06-28-2011, 06:40 PM
  2. Updating record based on textbox entry
    By timmy in forum Programming
    Replies: 16
    Last Post: 04-06-2011, 12:05 AM
  3. Replies: 2
    Last Post: 09-17-2010, 09:53 AM
  4. Replies: 3
    Last Post: 02-10-2010, 07:29 AM
  5. Textbox will not allow input
    By cwf in forum Forms
    Replies: 0
    Last Post: 04-04-2008, 04:08 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