473,412 Members | 2,994 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Filtering Form for a Report

Hello,

Ran into a snag while building my database. I have several forms but lets work with two for right now; Form1 and Form2 both have the same fields but use by two different users but both are connected to Report1. How can I get only the data in Form1 to show and vice versa for Form2. Is this possible?

David
Mar 20 '08 #1
23 1527
ADezii
8,834 Expert 8TB
Hello,

Ran into a snag while building my database. I have several forms but lets work with two for right now; Form1 and Form2 both have the same fields but use by two different users but both are connected to Report1. How can I get only the data in Form1 to show and vice versa for Form2. Is this possible?

David
You can actually assign the Recordset of one Form to another, this is probably the easiest Method:
Expand|Select|Wrap|Line Numbers
  1. Set Forms!Form2.Recordset = Forms!Form1.Recordset
  2.                      OR
  3. Set Forms!Form1.Recordset = Forms!Form2.Recordset
Mar 20 '08 #2
You can actually assign the Recordset of one Form to another, this is probably the easiest Method:
Expand|Select|Wrap|Line Numbers
  1. Set Forms!Form2.Recordset = Forms!Form1.Recordset
  2.                      OR
  3. Set Forms!Form1.Recordset = Forms!Form2.Recordset
You have to forgive me ADezii on my knowledge but where do I put this formula at exactly.

David
Mar 20 '08 #3
ADezii
8,834 Expert 8TB
You have to forgive me ADezii on my knowledge but where do I put this formula at exactly.

David
If you are opening FormB from FormA, then you can place the following code
in the Open() Event of FormB:
Expand|Select|Wrap|Line Numbers
  1. Set Forms!FormB.Recordset = Forms!FormA.Recordset
Mar 20 '08 #4
Dzii,

I see the formula and I havent tried it as of yet but I think I need to give clarity. When you open the form (without your coding) it gives me every record that any person has inputted from their individual form. All forms have the same data fields which are connected to one report the feeds off a master table. So when I am in form1 (for example) I get the everybodys record when I go to report (I push a command button that takes me to my report so I can print my records there) and I only want the records of the users form. Now after reading all this would that be the right coding I need. I really need your help on this one.

David
Mar 20 '08 #5
ADezii,

Have you came up with anything yet on the last reply.

David
Mar 21 '08 #6
ADezii
8,834 Expert 8TB
Dzii,

I see the formula and I havent tried it as of yet but I think I need to give clarity. When you open the form (without your coding) it gives me every record that any person has inputted from their individual form. All forms have the same data fields which are connected to one report the feeds off a master table. So when I am in form1 (for example) I get the everybodys record when I go to report (I push a command button that takes me to my report so I can print my records there) and I only want the records of the users form. Now after reading all this would that be the right coding I need. I really need your help on this one.

David
I only want the records of the users form
I am not exactly sure what you mean by this, please explain in greater detail.
Mar 21 '08 #7
I am not exactly sure what you mean by this, please explain in greater detail.
ADezii,

I apologize for the confusion and hope this clarifies the previous a bit more.

The user uses form1to input information into Masterdatabase(table). Form1 has a cmd button that when pushed it opens Report1. When Report1 opens it brings up every record in Masterdatabase. I only want the records that the user inputed into form1 to come up on Report1 when the cmd button is pushed.

David
Mar 21 '08 #8
ADezii
8,834 Expert 8TB
ADezii,

I apologize for the confusion and hope this clarifies the previous a bit more.

The user uses form1to input information into Masterdatabase(table). Form1 has a cmd button that when pushed it opens Report1. When Report1 opens it brings up every record in Masterdatabase. I only want the records that the user inputed into form1 to come up on Report1 when the cmd button is pushed.

David
  1. Is there any indicator that will pinpoint exactly what Records a specific User added?
  2. Is there a Primary Key Field in the MasterDatabase Table?
  3. If there is a PK Field in the MasterDatabase Table, what is its Data Type?
  4. If there is no Primary Key Field in MasterTable, is there an AutoNumber Field or a sequentially numbered Field?
Mar 21 '08 #9
  1. Is there any indicator that will pinpoint exactly what Records a specific User added?
  2. Is there a Primary Key Field in the MasterDatabase Table?
  3. If there is a PK Field in the MasterDatabase Table, what is its Data Type?
  4. If there is no Primary Key Field in MasterTable, is there an AutoNumber Field or a sequentially numbered Field?
ADezii,

- There is a Primary Key Field (Sequential Serial Number (Data Type Number) in the MasterDatabase Table. The information that identifies each user is their name (Data Type Text) entered in each record.
Mar 23 '08 #10
ADezii
8,834 Expert 8TB
ADezii,

- There is a Primary Key Field (Sequential Serial Number (Data Type Number) in the MasterDatabase Table. The information that identifies each user is their name (Data Type Text) entered in each record.
Just resubscribing, will return later.
Mar 23 '08 #11
ADezii
8,834 Expert 8TB
ADezii,

- There is a Primary Key Field (Sequential Serial Number (Data Type Number) in the MasterDatabase Table. The information that identifies each user is their name (Data Type Text) entered in each record.
This is basically a 2-step process:
  1. When the Form is initially opened, obtain the value of the Last Primary Key Entry, let's just assume it is 876.
  2. Open Report1 with the Criteria of > 876 on the Primary Key Field.
  3. Only the Records that the Current User entered will be reflected in Report1.
  4. For an additional User, you would have to Close then Re-open the Form to repeat the process.
  5. Is this what you are looking for, and do you need additional help on how to implement this?
Mar 23 '08 #12
This is basically a 2-step process:
  1. When the Form is initially opened, obtain the value of the Last Primary Key Entry, let's just assume it is 876.
  2. Open Report1 with the Criteria of > 876 on the Primary Key Field.
  3. Only the Records that the Current User entered will be reflected in Report1.
  4. For an additional User, you would have to Close then Re-open the Form to repeat the process.
  5. Is this what you are looking for, and do you need additional help on how to implement this?
Thanks ADezii,

I do need help on implementing this. I am however confused on just the Criteria of > 876 without having anything unique to the Current User. Wouldnt that just bring up every record from the MasterDataBase Table (from > 876) no matter who the user is?

David
Mar 23 '08 #13
ADezii
8,834 Expert 8TB
Thanks ADezii,

I do need help on implementing this. I am however confused on just the Criteria of > 876 without having anything unique to the Current User. Wouldnt that just bring up every record from the MasterDataBase Table (from > 876) no matter who the user is?

David
Assuming the Record Source for Report1 is the same or at least contains the [Name] Fields that exist in the Form, you could restrict Report1's Records to only those for the Current User by something similar to the following (assuming you have [LastName] and [FirstName] Fields, and your Text Box Names are txtLastName and txtFirstName):
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report1", acViewPreview, , "[LastName] = '" & Me![txtLastName] & "'" & _
  2.                  " And [FirstName] = '" & Me![txtFirstName] & "'"
NOTE: This would return 'ALL" Records from the MasterDataBase by the Current User, not the most newly entered ones. This is where the idea of capturing the Last Primary Key Value comes in, but if the above is what you want, that is fine.
Mar 23 '08 #14
Assuming the Record Source for Report1 is the same or at least contains the [Name] Fields that exist in the Form, you could restrict Report1's Records to only those for the Current User by something similar to the following (assuming you have [LastName] and [FirstName] Fields, and your Text Box Names are txtLastName and txtFirstName):
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report1", acViewPreview, , "[LastName] = '" & Me![txtLastName] & "'" & _
  2.                  " And [FirstName] = '" & Me![txtFirstName] & "'"
NOTE: This would return 'ALL" Records from the MasterDataBase by the Current User, not the most newly entered ones. This is where the idea of capturing the Last Primary Key Value comes in, but if the above is what you want, that is fine.
ADezii,
The coding that you mention is want I want but I also want current input.
What is the process on capturing th Last Primary Key Value for current input for the current date?

David
Mar 24 '08 #15
ADezii
8,834 Expert 8TB
ADezii,
The coding that you mention is want I want but I also want current input.
What is the process on capturing th Last Primary Key Value for current input for the current date?

David
  1. Place the following code in the General Declarations Section of your Form:
    Expand|Select|Wrap|Line Numbers
    1. Private lngLastValueEntered As Long
  2. Place the following code in your Form's Open() Event. Assuming your Primary Key Field is named [PrimaryKey], the Primary Key value of the last Record entered into the Database will be placed into the lngLastValueEntered Variable. I'm also assuming that your Form is not based on a Query with a Primary Sort on a Field other than [PrimaryKey].
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2.   lngLastValueEntered = DLast("[PrimaryKey]", "MasterDatabase")
    3. End Sub
  3. Place the following code in the Click() Event of a Command Button which will Open Report1. Make your own Field/Table Name substitutions whever necessary:
    Expand|Select|Wrap|Line Numbers
    1. 'Save any Edits in Progress
    2. If Me.Dirty = True Then Me.Dirty = False
    3.  
    4. DoCmd.OpenReport "rptEmployees", acViewPreview, , "[LastName] = '" & Me![LastName] & "'" & _
    5.                  " And [FirstName] = '" & Me![FirstName] & "' And [PrimaryKey] > " & _
    6.                  lngLastValueEntered
  4. Now, only those Records entered by the Current User, for the specific Session during which the Form was opened, will be displayed in the Report.
Mar 24 '08 #16
  1. Place the following code in the General Declarations Section of your Form:
    Expand|Select|Wrap|Line Numbers
    1. Private lngLastValueEntered As Long
  2. Place the following code in your Form's Open() Event. Assuming your Primary Key Field is named [PrimaryKey], the Primary Key value of the last Record entered into the Database will be placed into the lngLastValueEntered Variable. I'm also assuming that your Form is not based on a Query with a Primary Sort on a Field other than [PrimaryKey].
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2.   lngLastValueEntered = DLast("[PrimaryKey]", "MasterDatabase")
    3. End Sub
  3. Place the following code in the Click() Event of a Command Button which will Open Report1. Make your own Field/Table Name substitutions whever necessary:
    Expand|Select|Wrap|Line Numbers
    1. 'Save any Edits in Progress
    2. If Me.Dirty = True Then Me.Dirty = False
    3.  
    4. DoCmd.OpenReport "rptEmployees", acViewPreview, , "[LastName] = '" & Me![LastName] & "'" & _
    5.                  " And [FirstName] = '" & Me![FirstName] & "' And [PrimaryKey] > " & _
    6.                  lngLastValueEntered
  4. Now, only those Records entered by the Current User, for the specific Session during which the Form was opened, will be displayed in the Report.
ADzii,

What do you mean "Place the following code in the General Declarations Section of your Form?" I know how to bring the forms properties table up but not sure what the General Declarations Section is?

David
Mar 24 '08 #17
ADezii
8,834 Expert 8TB
ADzii,

What do you mean "Place the following code in the General Declarations Section of your Form?" I know how to bring the forms properties table up but not sure what the General Declarations Section is?

David
  1. In Form Design View.
  2. View ==> Code.
  3. Upper Left Hand Corner of Window (Combo Box) ==> Select (General)
  4. Upper Right Hand Corner of Window (Combo Box) ==> Select (Declarations)
Mar 25 '08 #18
  1. In Form Design View.
  2. View ==> Code.
  3. Upper Left Hand Corner of Window (Combo Box) ==> Select (General)
  4. Upper Right Hand Corner of Window (Combo Box) ==> Select (Declarations)
Adezii,
I have a run time error of 2501 and points to this as being of error
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "Report1", acViewPreview, , "[Instructor] = '" & Me![Instructor] & "'" & _
  2.                  " And [InstTitle] = '" & Me![InstTitle] & "' And [CertSerialNum] > " & _
  3.                  lngLastValueEntered
David
Mar 25 '08 #19
NeoPa
32,556 Expert Mod 16PB
You may want to post the error message associated with error #2501.
Mar 25 '08 #20
You may want to post the error message associated with error #2501.
NeoPa,

I am glad you answered NeoPa. I found out it wasnt the previous coding of Adezii but the coding you passed to me previously. Problem: When data is in the report it gives no error but when their is no data then it comes up with run time error 2501 and you can either end process or debug the command button.

Code given to me
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.   Cancel = True
  3. End Sub
When Debug is initiated it goes to Private Sub code below and Highlights the DoCmd line
Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintLMCert_Click()
  2.  
  3.     DoCmd.OpenReport "ChristineMcLaurinCert", acPreview
  4.  
  5. End Sub
You have any solutions?

Also this only reacts this way on one report the other report works great with your coding.

David
Mar 25 '08 #21
NeoPa
32,556 Expert Mod 16PB
Well, I'm happy to be involved then David, but could we start with the error message?
Mar 25 '08 #22
Well, I'm happy to be involved then David, but could we start with the error message?

Taken care of NeoPa,

I replaced the previous coding with the below coding and it fix the problem.
Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintLMCert_Click()
  2.  
  3. On Error GoTo Err_PrintLMCert_Click
  4.     Dim stDocChris As String
  5.     stDocChris = "ChristineMcLaurinCert"
  6.    DoCmd.OpenReport stDocChris, acPreview
  7.  
  8. Exit_PrintLMCert_Click:
  9.     Exit Sub
  10.  
  11. Err_PrintLMCert_Click:
  12.     MsgBox Err.Description
  13.     Resume Exit_PrintLMCert_Click
  14.  
  15. End Sub
But I still need your help with my check box. So I am going to exit from this thread and go back to the one we started a week or so ago.

Thanks David
Mar 25 '08 #23
NeoPa
32,556 Expert Mod 16PB
Well, I guess I'll get another thread popping up tomorrow then (It's just after midnight here now).

Let me just draw you attention to the rules about posting code while I'm here. They must always be posted in [ CODE] tags. When posting, look for the button with the # on.
Mar 26 '08 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dalan | last post by:
Okay, I have worked on this and then some, but cannot seem to crack it. So if someone can straighten my code out, or suggest a new approach, then I'm all ears. Here goes: I have two tables - one...
5
by: Richard | last post by:
Hi, I have a form that take some time to load due to many comboboxes and at least 8 subforms. When I filter or sort the main form I get an error message and then Access shuts down. They ask if...
1
by: diskoduro | last post by:
Hi! I'm trying to get help to an unexpected problem that has appeared while I was writing a new application. I want to opeon a report of product sales by filtering previously from a listbox in a...
0
by: Scott Loupin | last post by:
I've got two databases with similar data in them (WestSide and EastSide). I've set up two identical reports that is filtered by date and the client name. I'm using one form to do the filtering. ...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
1
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including...
2
by: Gerry Abbott | last post by:
Hi all. Im using a form's recordsource for a report. which works fine Me.RecordSource = Forms("frmdate01").Form.Controls("HoldLog").Form.Controls("frmHoldLog01").Form.RecordSource Ive got a...
8
by: | last post by:
hi, i have a form on which a user can choose specific criteria such as dates etc, in order to filter the report that is called from the form. i do this by using the Where section of the...
3
by: TS | last post by:
Hi all, In my windows form, I need the user to select a client name from a combo box and click on a button that opens another form having CRViewer showing the data for that client selected. I...
3
by: paquer | last post by:
On my Main form I have a Command Button that opens a Subform in order to create a new Subform record. At this point I want the subform to show only the new record being created. Not all the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.