Results 1 to 6 of 6
  1. #1
    ccgirl5 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2015
    Posts
    4

    retrieve textbox value from current report in vba open report function

    UPDATED: not sure if I need to create another post, but updating this one. (removed the subreport)




    I created a report which opens from a Form using an on_click, do cmd event procedure
    Code:
    DoCmd.OpenReport stDocName, acViewReport, , "[qrycatlist].[evtdate]= 
    Forms!    [hsubform]!evtdate and [qrycatlist].[evtcategory]= Forms!
    [hsubform]!evcats and [qrycatlist].[evtod]= Forms![hsubform]!evtod") 
    All is based on date, category, time The report is named: caterpt1
    Within the header of the report (catrpt), I have a textbox that "counts" the number of people in the category based on the reports date, time, category.


    The txtbox field called (tcounts) has a number of 26 (for this report). Using an expression builder I created the following
    Code:
        tcounts=DCount("*","[qrycatlist]","[qrycatlist].[evtdate]= [tdate] and
    [qrycatlist].[evtcategory]= [tcats]")
    Can the Private Sub Report_Open(Cancel As Integer) refer to the txtbox field name tcounts on the report????????


    And if it can, how do I get it to refer to the txtbox tcount. I've searched and searched and can't find the answer.


    How do I get the function to retrieve the "tcounts" field.
    Code:
    Private iTotal As Integer
    
    
    Private Sub Report_Open(Cancel As Integer)
     get total record count
        iTotal = Report!tcounts
     end Sub
    OR


    Code:
       Private Sub Report_Open(Cancel As Integer)
      ' get total record count
    iTotal = DCount("*", "qrycatlist") <----this needs to have the where
         values of the report.  (date, time, category)
    End Sub
    The iTotal value is not working. I don't think I am typing it in correctly or not using the right function.


    I keep getting errors 2465 (can't find the field)


    If i were to use the 2nd private sub report open, how would I pull the values from the main report?


    I can't get the function to use it!!! Almost there but can't seem to get it all to jive. HELP!!!


    The purpose of this report is to list the people in the event based on category, date and time and create extra lines based on the total number of people. (50 lines show 26 with people, and remaining blank lines with numbers) IE to write in .


    i have a function after the one above the uses the iTotal. (see post #3)
    Last edited by ccgirl5; 02-25-2017 at 10:25 AM. Reason: new idea, don't need the subreport

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Instead of iTotal, fill the textbox on the form,
    txtBox= Dcount....

  3. #3
    ccgirl5 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2015
    Posts
    4
    Thank you for the reply. I need the itotal number to figure out how many "blank" numbered rows needed to fill the rest of the page.

    The rest of the code is below.

    If there are lets say 26 people, I need to show lets say 24 more numbered, but blank rows. I tried many different ways to do this, and found this way the best. It continues the rows until 50, but formats the row's information "white." I also created away to continue to number the rows until 50 (but that is also on the main report page..that's why the visible is there below)

    Code:
    iLines = 50
    
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    
    
    
      Static iLine As Integer
      iLine = iLine + 1
      If iLine < iTotal Then
        
      ElseIf iLine = iTotal Then
        
        If iLine < iLines Then Me.NextRecord = False
      Else
      Dim lngNextID As Long
     lngNextID = Val(iLine)
      
        
       Me!enum.ForeColor = vbWhite
        Me!ename.ForeColor = vbWhite
    
        Me!enum2.Visible = True
     '   Me.ero2 = iLines
     Me.enum2= lngNextID
      
        If iLine < iLines Then Me.NextRecord = False
      End If
    End Sub

  4. #4
    NTC is offline VIP
    Windows 10 Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    I recommend you manage your record set count at the query level, not at the report level.

    It is relatively simple to manage the record set count if it is always suppose to be 50; first have a '50 table' that is 50 records numbered 1 to 50; outer join the 50 table to the data records to create a 50 record set for your report.

  5. #5
    ccgirl5 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2015
    Posts
    4
    That's a brilliant idea!!!!!! Thanks so much!!! Very simple and less coding complication.

  6. #6
    ccgirl5 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2015
    Posts
    4
    Quote Originally Posted by NTC View Post
    I recommend you manage your record set count at the query level, not at the report level.

    It is relatively simple to manage the record set count if it is always suppose to be 50; first have a '50 table' that is 50 records numbered 1 to 50; outer join the 50 table to the data records to create a 50 record set for your report.
    This worked, until I tried to use criteria in the where clause

    is there a way to show all the field on the tbl50 (number 1-50) and the info for the event table, where the event table has where statement. ?


    ++++++++++++++figured it out, see below++++++++++++

    I figured it out. I used a select inside the query and used the form!properties in the subselect to get the criteria needed.

    so when I clicked on the form it passed the form information to the select in the query. Kinda tricky, but got it.

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

Similar Threads

  1. Replies: 6
    Last Post: 06-24-2016, 06:59 AM
  2. Open Report w DateAdd function
    By libraccess in forum Programming
    Replies: 3
    Last Post: 02-21-2013, 12:31 AM
  3. Open Report From Subform on Main Form
    By burrina in forum Forms
    Replies: 4
    Last Post: 12-25-2012, 08:11 PM
  4. Replies: 1
    Last Post: 03-07-2012, 09:00 AM
  5. Replies: 0
    Last Post: 10-24-2008, 11:20 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