J
Jean-Paul
I think this is a rather basic question and difficult to explain, but
I'll try
I have this form with 1 entryfield and 1 puhbutton
In this entryfield I enter a name, or part of a name
I click the pushbutton and another form opens, based upon what I entered
in the first form
The code for the pushbutton of the first form is:
Private Sub Knop13_Click()
If IsNull(Me!Naam_lk) = False Then
If MsgBox("Je koos een naam", vbOKOnly, "Let op") Then
End If
End If
If IsNull(Me!Naam_lk) = False Then
Dim g As Form, f As Form
Dim db As Database
Set db = CurrentDb()
Dim tb As Recordset
Dim sql As String
Set g = Forms![Selectie]
DoCmd.OpenForm ("leerkrachten")
Set f = Forms![leerkrachten]
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.NAAM= '" & Replace(g!Naam_lk, "'", "''") & "' ;"
Set tb = db.OpenRecordset(sql)
If tb.RecordCount = 0 Then
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.Naam Like '" & "*" & Replace(g!Naam_lk, "'", "''") & "*" & "';"
Set tb = db.OpenRecordset(sql)
End If
f!nm_lk = tb!naam
f!str_lk = tb!straat
f!gem_lk = tb!plaats
f!Geb_lk = tb!geboortedatum
f!PN_lk = tb!postnummer
f!GSM_lk = tb!GSM
f!mail_lk = tb!Email
f!Synd_lk = tb!gesyndiceerd
f!Nu_lk = tb![Nu nog actief]
End If
End Sub
(I'm sure this code can be a lot better so any comment is welcome)
The newly opened form is called "leerkrachten"
Everything works just fine.
On this second form I created a pushbutton to navigate through the
recordset I created through the code above
But, when I click the pushbutton nothing happens... i have the idea I
"lost" the recordset
What am I doing wrong and how to solve this problem
Thanks you all
JP
I'll try
I have this form with 1 entryfield and 1 puhbutton
In this entryfield I enter a name, or part of a name
I click the pushbutton and another form opens, based upon what I entered
in the first form
The code for the pushbutton of the first form is:
Private Sub Knop13_Click()
If IsNull(Me!Naam_lk) = False Then
If MsgBox("Je koos een naam", vbOKOnly, "Let op") Then
End If
End If
If IsNull(Me!Naam_lk) = False Then
Dim g As Form, f As Form
Dim db As Database
Set db = CurrentDb()
Dim tb As Recordset
Dim sql As String
Set g = Forms![Selectie]
DoCmd.OpenForm ("leerkrachten")
Set f = Forms![leerkrachten]
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.NAAM= '" & Replace(g!Naam_lk, "'", "''") & "' ;"
Set tb = db.OpenRecordset(sql)
If tb.RecordCount = 0 Then
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.Naam Like '" & "*" & Replace(g!Naam_lk, "'", "''") & "*" & "';"
Set tb = db.OpenRecordset(sql)
End If
f!nm_lk = tb!naam
f!str_lk = tb!straat
f!gem_lk = tb!plaats
f!Geb_lk = tb!geboortedatum
f!PN_lk = tb!postnummer
f!GSM_lk = tb!GSM
f!mail_lk = tb!Email
f!Synd_lk = tb!gesyndiceerd
f!Nu_lk = tb![Nu nog actief]
End If
End Sub
(I'm sure this code can be a lot better so any comment is welcome)
The newly opened form is called "leerkrachten"
Everything works just fine.
On this second form I created a pushbutton to navigate through the
recordset I created through the code above
But, when I click the pushbutton nothing happens... i have the idea I
"lost" the recordset
What am I doing wrong and how to solve this problem
Thanks you all
JP