how to limit a form to only one record from a table other than form's source table (1 Viewer)

shwan

Registered User.
Local time
Today, 11:00
Joined
Nov 18, 2017
Messages
13
Hello,
So I have this simple database that contains only two tables. one contains customers information the other contains their payments.
I made a main form that pulls information from a query based on these two tables. When the user clicks on a record in this main form another form opens that shows the payments of this specific record, I did that using simple code in the where clause in on click event of the name field. My problem now is that when the user wants to add new payment on this second form they can enter a payment to any other customer not only the one that they clicked in the main form. How can I limit the second form to only the record that the user clicked in the main form. I attached my database.
Thank you very much
 

Attachments

  • patients.accdb
    1.8 MB · Views: 78

isladogs

MVP / VIP
Local time
Today, 18:00
Joined
Jan 14, 2017
Messages
18,186
I've not looked at your db.
All you need to do is open the second form filtered to the required record i.e. customer.
 

shwan

Registered User.
Local time
Today, 11:00
Joined
Nov 18, 2017
Messages
13
I've not looked at your db.
All you need to do is open the second form filtered to the required record i.e. customer.

Is not that what where clause supposed to do. I think when the form opens it is already filtered since it shows all the payment related to one record only, but still, you can enter a new payment unrelated to that record and I want to prevent that.
 

isladogs

MVP / VIP
Local time
Today, 18:00
Joined
Jan 14, 2017
Messages
18,186
Is not that what where clause supposed to do. I think when the form opens it is already filtered since it shows all the payment related to one record only, but still, you can enter a new payment unrelated to that record and I want to prevent that.

Try locking any controls that you don't want the user to edit
 

JHB

Have been here a while
Local time
Today, 19:00
Joined
Jun 17, 2012
Messages
7,732
Is not that what where clause supposed to do. I think when the form opens it is already filtered since it shows all the payment related to one record only, but still, you can enter a new payment unrelated to that record and I want to prevent that.
Yes it is correct, it is filtered but it is not locked to a certain record (Id).
You need a constellation know as Main-/Sub-form.
 

Users who are viewing this thread

Top Bottom