Open a form with all records, but you have to see a specific recor

G

Guest

hello there,

I hope somebody can help me. Here is my problem.

I have 2 forms.
the first form contains specific data about a person (id-person
(autonumbering field),Name, first name, number, ....)
The second form contains also this information, but is linked to a subform
with additional information.
You have to fill in the first form , because the same fields in the second
form are disabled. You can close the first form (with a command button). This
closes the first form and opens the second form. Now I want to see the
record I just made in the first form. But not only this one, I must be able
to see all the other records.
How do I have to do this? I've already done a number of things, but they
only give me the specified record.
 
G

Guest

Hi Sabineke,

Do you open the second form with a where condition or a filter on the ID?
If you do that it's obvious that you can see and navigate just on this
record 'cause those clause limits the recordsource of the form to the records
matching the condition. If you wanna display the record you just added but
you wanna also be able to navigate to the others you must go to the record
for displaying and not filter the recordsource.

HTH Paolo
 
G

Guest

I know that I can't do it like that. (putting in a where condition or a
filter)
What I want it to do is, that when I open the form it goes to the record I
just made in the other form. In this way I don't have to search for the
right record and can start putting in the additional information. I think
maybe it is possible with recordcount, put the problem is that the second
form is based on a query where I sort on the name and first name. So the
recordnumbers do not match.

The code I have written for the command button is like this :

Private Sub
Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click()
On Error GoTo
Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

If Not IsNull(ID_Personeelslid) Then
idnr = ID_Personeelslid
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project", , , WhereCondition = "[ID
Personeelslid] = " & idnr

Else
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project"
End If

Exit_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click:
Exit Sub

Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click:
MsgBox Err.Description
Resume
Exit_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

End Sub


Thanks for your help.
Sabineke
 
J

John Spencer

First change the calling code so you pass the IDNr as an Open Argument to
the called form

Private Sub
Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click()
On Error GoTo
Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

If Not IsNull(ID_Personeelslid) Then
idnr = ID_Personeelslid
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project", OpenArgs:= idnr & ""

Else
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project"
End If


Now in the form you have called use the OpenArg value to locate the record
you want. In the Load Event you can use code as follows.

Private Sub Form_Load()

If Len(Me.OpenArgs & "") > 0 Then
Me.RecordsetClone.FindFirst "[Field]= " & Me.OpenArgs
If Me.RecordsetClone.NoMatch = False Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End If

End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Sabineke said:
I know that I can't do it like that. (putting in a where condition or a
filter)
What I want it to do is, that when I open the form it goes to the record I
just made in the other form. In this way I don't have to search for the
right record and can start putting in the additional information. I think
maybe it is possible with recordcount, put the problem is that the second
form is based on a query where I sort on the name and first name. So the
recordnumbers do not match.

The code I have written for the command button is like this :

Private Sub
Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click()
On Error GoTo
Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

If Not IsNull(ID_Personeelslid) Then
idnr = ID_Personeelslid
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project", , , WhereCondition =
"[ID
Personeelslid] = " & idnr

Else
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project"
End If

Exit_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click:
Exit Sub

Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click:
MsgBox Err.Description
Resume
Exit_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

End Sub


Thanks for your help.
Sabineke


Paolo said:
Hi Sabineke,

Do you open the second form with a where condition or a filter on the ID?
If you do that it's obvious that you can see and navigate just on this
record 'cause those clause limits the recordsource of the form to the
records
matching the condition. If you wanna display the record you just added
but
you wanna also be able to navigate to the others you must go to the
record
for displaying and not filter the recordsource.

HTH Paolo
 
G

Guest

Thank you very much John.
It works!!!

Sabineke

John Spencer said:
First change the calling code so you pass the IDNr as an Open Argument to
the called form

Private Sub
Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click()
On Error GoTo
Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

If Not IsNull(ID_Personeelslid) Then
idnr = ID_Personeelslid
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project", OpenArgs:= idnr & ""

Else
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project"
End If


Now in the form you have called use the OpenArg value to locate the record
you want. In the Load Event you can use code as follows.

Private Sub Form_Load()

If Len(Me.OpenArgs & "") > 0 Then
Me.RecordsetClone.FindFirst "[Field]= " & Me.OpenArgs
If Me.RecordsetClone.NoMatch = False Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End If

End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Sabineke said:
I know that I can't do it like that. (putting in a where condition or a
filter)
What I want it to do is, that when I open the form it goes to the record I
just made in the other form. In this way I don't have to search for the
right record and can start putting in the additional information. I think
maybe it is possible with recordcount, put the problem is that the second
form is based on a query where I sort on the name and first name. So the
recordnumbers do not match.

The code I have written for the command button is like this :

Private Sub
Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click()
On Error GoTo
Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

If Not IsNull(ID_Personeelslid) Then
idnr = ID_Personeelslid
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project", , , WhereCondition =
"[ID
Personeelslid] = " & idnr

Else
DoCmd.Close
DoCmd.OpenForm "Frm Ingave personeel/project"
End If

Exit_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click:
Exit Sub

Err_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click:
MsgBox Err.Description
Resume
Exit_Sluiten_frm_Nieuw_personeelslid_en_tonen_in_peroneel_project_Click

End Sub


Thanks for your help.
Sabineke


Paolo said:
Hi Sabineke,

Do you open the second form with a where condition or a filter on the ID?
If you do that it's obvious that you can see and navigate just on this
record 'cause those clause limits the recordsource of the form to the
records
matching the condition. If you wanna display the record you just added
but
you wanna also be able to navigate to the others you must go to the
record
for displaying and not filter the recordsource.

HTH Paolo

:

hello there,

I hope somebody can help me. Here is my problem.

I have 2 forms.
the first form contains specific data about a person (id-person
(autonumbering field),Name, first name, number, ....)
The second form contains also this information, but is linked to a
subform
with additional information.
You have to fill in the first form , because the same fields in the
second
form are disabled. You can close the first form (with a command
button). This
closes the first form and opens the second form. Now I want to see the
record I just made in the first form. But not only this one, I must be
able
to see all the other records.
How do I have to do this? I've already done a number of things, but
they
only give me the specified record.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top