Full Version: Let's Start From Scratch
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
CarsonJ
Hello,

I have been workign on a database project over the last several months for my company. I am a co-op student(basically a paid intern) who has had no formal training in programming.

I have a form which will display powerpoints, excels, and pictures based on the selections of two combo boxes. The user can then use the form to record what work was done by pressing a button. The button activiates coding which stores the pertinate information in a table. It works quite well and doesn't seem to have any more bugs at the momnent.

However, this record of work requires that the supervisors can be able to look up the work done. I want to create a reprt that would dispay the table with the stored information based on the selections of two comboboxes (I plan to recycle the coding from the form to accomplish that portion). I have no knowledge of reports and what they do, so I'm limited by experience as to what I understand. I know enough to see that this should be possible, it would just require a bit of help from people more knowledgable..

Ultimately I want help creating a report that would display the entries in the table using the two combo boxes as filters. If you have any suggestions, ideas, or links that you think would be helpful, please post them. I am still learning about what Access can do and everything you suggest helps me gain that much more information.

TIA
CarsonJ

Here is the code that I use to populate the two combo boxes if that helps:
CODE
'Searches the designated directory for folders and then will list folder names in combobox1
  myPath = "J:\Directory\"
  MyName = Dir(myPath, vbDirectory)
  Do While Len(MyName) > 0
    If MyName <> "." And MyName <> ".." Then
      If (GetAttr(myPath & MyName) And vbDirectory) = vbDirectory Then
        MyName2 = MyName2 & MyName & ";"
      End If
    End If
    MyName = Dir
  Loop
  
  If Len(MyName2) > 0 Then
    MyName2 = Left$(MyName2, Len(MyName2) - 1)
    With Me.Combo0
      .RowSource = MyName2
      .RowSourceType = "Value List"
    End With
  End If

End Sub
Private Sub Combo0_AfterUpdate()
'Upon selecting one of the folder names, will search for excels in that folder

Dim strDir As String
Dim filter As String

filter = "*.xls"
strDir = "J:\Directory\" & Combo0.Text
File_Search strDir, filter

End Sub
'will populate the 2nd combobox with the filenames of the excels found
Sub File_Search(dirStr As String, filter As String)
Dim Search_path, Search_Filter, Search_Fullname As String
Dim DocName As String
Dim i As Long
DocName = Dir(dirStr & "\" & filter)

Do Until DocName = ""
Search_Fullname = Search_Fullname & ";" & DocName
DocName = Dir
Loop

With Me.Combo1
.RowSource = Search_Fullname
.RowSourceType = "Value List"
End With
End Sub
theDBguy
Hi CarsonJ,

Were your Topic Title referring to this earlier discussion?

Just want to make sure prospective responders get the background info, if needed.

Just my 2 cents... 2cents.gif
CarsonJ
Indeed DBguy. Instead of having one mega topic to figure out all the parts of this program, I broke it down so that it is easier to manage. Eventually once it is complete, I plan on submitting it to the Archive for everyone to use. In total, it'll end up being over 300 lines of code for a fairly powerful tool, if I do say so myself.

The link DBguy provided is a discussion on making the query that grabs the information out of the form and stores it into the table. From there this report either needs to filter the results and display them or import the table wholesale and then filte them. Either way should work, it would come down to which is easiest and fastest for the user.

-CarsonJ
CarsonJ
I really should have titled this topic something different...

Anyway, I have a report. It's nice and lovely when it comes to putting all the records from the table onto the report. However, there are two issues that come to mind.

First, the records are all on 1 page. I'm going to have at least 4500 entries in this table. How do I set a limit to the number of entries on a page, say 50, beofer another page is created?
Second, How can I set up a way for the user to sort that inforamtion so that they see only a small portion of the entries, anywhere between 50~100? I can make the report sort the info when it comes in, but that does me little good if I'm looking for a specific set of entries that are scattered throughout the table. SIcne this is a record of tool cleanings, it is possible for several days to go by without cleanings. Given that there are about 70 entries a day, you can see how quickly those two entries will be seperated.

TIA,
CarsonJ
theDBguy
Hi CarsonJ,

QUOTE (CarsonJ @ May 11 2012, 08:08 AM) *
...Given that there are about 70 entries a day, you can see how quickly those two entries will be seperated.

Actually, we can't... (at least, I can't). We are not familiar with your business process as you do so things that are obvious to you may not be obvious to us.

Anyway, reports can be sorted and grouped. If you group the records in your report, it wouldn't matter how many other records get inserted in between them, the "cleaning" records will still stay together in your report.

Just my 2 cents... 2cents.gif
CarsonJ
Ok, let me re-explain myself,

I was merely trying to illistrate that if a tool is cleaned 4 days apart, there's going to be roughly 280 entries between the instances. Given that the users would be looking at a list of all entries that are in the table, over 4K at the most, it would be very hard for the operator to find all the instances that that tool was cleaned.

I am trying to find a way to sort the fields that are imported from the table so that what is shown to the users is what they designate. For example, if they only want to see tool #12345 they would select it, either from a combobox or some other means, and the repert would bring up all entries of 12345 being cleaned that are in the table. That being said, if instead the report imported all the entries in the table and then brought the entries pertaining to 12345 to the top of the list, I would be fine with that.

I will work on clarifying myself better in the future,
CarsonJ
theDBguy
Hi CarsonJ,

Thanks for the clarification but please keep in mind that we are not there with you and do not see what you see.

I have the impression that you know how to filter a report so that it only shows the records you need to see, but based on your description, it sounds like you forgot how to do that.

So, in case you did not know how to filter a report based on user's input, here's an example:

1. Create a report based on your table or query so that when you open this report, all the records show up.
2. Create a form with textbox or combobox where the user will enter or select the value they want to "filter" the report with.
3. On the form, add a command button to open the report. Let's say you want the user to filter the report by the Tool ID number, then in the Click event of the button, use this code:

DoCmd.OpenReport "ReportName", acViewPreview, , "[ToolID]=" & Me.TextboxName

Note: That code assumes the name of the field we want to filter is "ToolID" and that it is a numeric field.

Just my 2 cents... 2cents.gif
CarsonJ
I know enough about Access to know what I want it to do, but I haven't had the experience or the teaching to make it happen.

DoCmd.OpenReport "Service Records", acViewPreview, , "[Part Number]=" & Me.TextboxName

This would be the code, but how do I change it to be text? I have to keep the Part Number field as text since some fo the numbers have letters.

theDBguy
Hi,

For text, you just need to enclose the value in single quotes. For example:

CODE
DoCmd... , "[FieldName]='" & Variable & "'"

Just my 2 cents... 2cents.gif
CarsonJ
Yep that did it. Thanks again DB.

I do have another thing if you know how to do it. This is more for austetics and ease of use. Would it be possible to have the code populate a subreport in the form instead of generating a new one? This would be more to facilitate the users so they didn't have to navigate away from the form if they wanted to see the records of different parts.

Like I said, if you know how to great,
CarsonJ
theDBguy
Hi CarsonJ,

Not sure I fully understand your question but if you're asking if it's possible for the user to enter or select a different value in the form to update the records showing on the report, then I'd say give it a try. If you followed the instructions I gave you earlier, it should allow the user to change the selection and hit the button to update the report

Please let me know if that doesn't work.

Just my 2 cents... 2cents.gif
CarsonJ
I tried out my idea the following the code you provided and it will generate a report based on what is in the combobox if there isn't a generated report already open. It also does not update the generated report if it is open.

I would like to have the report be generated in a sub-report so that the operator would have the ease to change between parts with out the hassle of switching between the form and report. Think of it like this: THere will be a combobox and button on the top of the form. Below them is the sub-report. Selecting a part from the combobox and clicking the button will cause the sub-report to be populated with the entries in the ServiceRecords table that are of that part.

I can't really think of a way to better explain it.
darnellk
Pardon my interruption, but could I just ask why you want this to be a report and not just in a form or subform? Typically a report will be used for printing hard or soft copies for archiving or offline purposes, but it sounds like what you're doing is querying data about a particular item, and not having to print it. If this were just in a form, you could easily refresh the data if a different item was selected.
theDBguy
Hi CarsonJ,

Based on Darnell's idea, try the following:

1. Create a blank form called "Form1."
2. In the Header section of Form1, add a combobox for the user to make the selection and name it "cboMyCombo."
3. Create a query based on your table and in the criteria row for the field you want to be filtered by the combobox, enter the following:

Forms!Form1.cboMyCombo

4. In the Record Source property of Form1, select the name of the query you created in step 3 from the dropdown choices.
5. Add the fields you want to see from the query into the Details section of the form. Put them side-by-side for now.
6. In the Default View property of Form1, select "Continuous Forms" from the dropdown.
7. Adjust the height of the Details section to eliminate wasted/white space.
8. In the AfterUpdate event of the Combobox, use the following code:

Me.Requery

9. Save the form and try it.

Hope that's close enough to what you need.

Just my 2 cents... 2cents.gif
CarsonJ
Ooo! That is awesome! shocked.gif I cam eout really nicely. I also made the fields locked so that they couldn't be tampered with, not that it would affect the records anyways.

Showing it to some of the supervisors, they like it, so I think this is what we're going to go with.

Thank you DB and darnellk!

-CarsonJ
theDBguy
Hi CarsonJ,

yw.gif

Darnell and I are happy to help. Good luck with your project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.