Troulbe with Where Clause (1 Viewer)

andy1968

Registered User.
Local time
Today, 13:22
Joined
May 9, 2018
Messages
131
I'm trying to open one from from another with a where clause to take me to the same record.


From frmToDoListAll, in the Subform, I have the code:

Private Sub What_DblClick(Cancel As Integer)


DoCmd.OpenForm "frmToDoListEntry", , , "[ID]=" & Me.[ID] & ""


End Sub


frmToDoListEntry shows all the records.


I've attached the database.
 

Attachments

  • fromFilter.zip
    75.7 KB · Views: 30

isladogs

MVP / VIP
Local time
Today, 21:22
Joined
Jan 14, 2017
Messages
18,209
You need to force a save before opening the form
Add this before the open form line

If Me.Dirty Then Me.Dirty = False
 

andy1968

Registered User.
Local time
Today, 13:22
Joined
May 9, 2018
Messages
131
OK.


Changed the code to:


If Me.Dirty Then Me.Dirty = False

DoCmd.OpenForm "frmToDoListEntry", , , "[ID]=" & Me.[ID] & ""


Still get all the records.
 

June7

AWF VIP
Local time
Today, 12:22
Joined
Mar 9, 2014
Messages
5,466
frmToDoListEntry has DataEntry set to Yes. It should only open to NewRecord row. Why it is opening to any records at all is a mystery.

frmToDoListEntry opens to all records when frmToDoRecall is open. When it is not, then frmToDoListEntry opens to only New Record row. More mystery. Must be code behind frmToDoListEntry controlling this. Will look at later.


Won't make a difference, but the & "" is not necessary.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 21:22
Joined
Jan 14, 2017
Messages
18,209
The me.dirty line means you get the correct person!
I also removed the &"" as june mentioned.

It seems to be working but maybe I'm missing something. See attached
 

Attachments

  • fromFilter.zip
    85.9 KB · Views: 41

andy1968

Registered User.
Local time
Today, 13:22
Joined
May 9, 2018
Messages
131
June,


Yes, there is code behind the form to change it from dataentry true to false.


Ridders,


Downloaded your version.


It still opens to all the records.
 

June7

AWF VIP
Local time
Today, 12:22
Joined
Mar 9, 2014
Messages
5,466
Suggest you set the DataEntry property to No. Then code:

Private Sub Form_Load()
If Not CurrentProject.AllForms("frmToDoRecall").IsLoaded Then
Me.DataEntry = True
End If
End Sub
 

isladogs

MVP / VIP
Local time
Today, 21:22
Joined
Jan 14, 2017
Messages
18,209
Ridders,
Downloaded your version.
It still opens to all the records.

Then I am missing something. Which form shows all the record?
The first one or the one opened by clicking the 'What' control?
Sorry can't remember form names as its not on this computer
 

andy1968

Registered User.
Local time
Today, 13:22
Joined
May 9, 2018
Messages
131
From the subform "frmToDoListAll" I want to double click on the "What" field to open the form "frmToDoListEntry" and display the record that I click on.


I've attached some screen shots.


The onload for "frmToDoListEntry" set it's data entry to false
 

Attachments

  • filter.zip
    84.6 KB · Views: 49

andy1968

Registered User.
Local time
Today, 13:22
Joined
May 9, 2018
Messages
131
June7 - your solution works. Thanks! First time I looked at it I missed the Not in the If statement.


Mike, your's work too. I don't want to use 2 separate forms though. One form is easier to manage.
 

Users who are viewing this thread

Top Bottom