Results 1 to 4 of 4
  1. #1
    NetAdmin is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    2

    Access Report - Set Text box value from one of two query fields based on criteria...

    I have a situation which I can't figure out, but seems like it should be easy to do. I was tasked with maintaining the home built Access applications here at work after the programmer quit.
    I cannot re-write this whole application (I Could - but my boss won't let me spend the time on it).

    I have a particular query which pulls data from a table, and is then used in a report. For example...

    Field1 = name (text field)
    Field2 = new_name (text field)
    field3 through field10 = more related data

    there are about 300 records of which about 100 have a entry in field2 - the rest are blank in field2

    Here is my situation:

    Report has a textbox on it txtName
    I want to set the txtName box to field2 if it has an entry, and set it to field1 if field2 is blank.



    Can anyone shed some light on how to pull this off? Thanks to all who take the time to read and reply - I do appreciate your time.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You could have 2 rpts, one for blank fld2 and one for not...its the SAME report but 2 different queries.
    an if on the open report button

    Code:
    if isnull(field2) then
       docmd.openreport "rReport ", acViewPreview
    else
       docmd.openreport "rReport with Fld2", acViewPreview
    end if

    or 1 report with a FILTER the fld2 with a value

    Code:
    DoCmd.OpenReport "report", acViewPreview, , "[field2]='" & Forms!frmMain!field2 & "'"

  3. #3
    NetAdmin is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2014
    Posts
    2
    Clarification:

    The final report has to list all 300 records on one report, but with the above needs fulfilled too - if the field2 field has an entry that has to be the txtName entry for that record, otherwise it has to be field1's entry.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Right .
    "rReport" would use field1 entry
    "rReport with Fld2" would used field2 entry

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 4
    Last Post: 02-12-2014, 03:44 PM
  3. Replies: 1
    Last Post: 10-29-2012, 08:15 AM
  4. Replies: 2
    Last Post: 05-16-2012, 04:45 PM
  5. Replies: 12
    Last Post: 05-07-2012, 12:41 PM

Tags for this Thread

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