J
Jean-Paul
I created a form with 1 entryfield and a pushbutton
I enter a full name or part of a name in this entryfield
When I click the pushbutton a form is opened and following code runs
Private Sub Form_Load()
Dim f As Form
Dim db As Database
Set db = CurrentDb()
Dim tb As Recordset
Dim sql As String
Set f = Forms![leerkrachten]
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.NAAM= '" & Replace(Forms!Selectie!Naam_lk, "'", "''") & "' ;"
Set tb = db.OpenRecordset(sql)
If tb.RecordCount = 0 Then
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.Naam Like '" & "*" & Replace(Forms!Selectie!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 Sub
The correct record is shown.... so far no problem.
On this newly opened record, I created a pushbutton "Next"
Clicking on this button should show me the next record in the recordset
Alas, I get a message saying the program can not go to the desired record.
The code is:
Private Sub Knop28_Click()
DoCmd.GoToRecord acDataForm, "leerkrachten", acNext
End Sub
How to solve this problem?
Thank you so much
I enter a full name or part of a name in this entryfield
When I click the pushbutton a form is opened and following code runs
Private Sub Form_Load()
Dim f As Form
Dim db As Database
Set db = CurrentDb()
Dim tb As Recordset
Dim sql As String
Set f = Forms![leerkrachten]
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.NAAM= '" & Replace(Forms!Selectie!Naam_lk, "'", "''") & "' ;"
Set tb = db.OpenRecordset(sql)
If tb.RecordCount = 0 Then
sql = "SELECT leerkrachten.* FROM leerkrachten WHERE
leerkrachten.Naam Like '" & "*" & Replace(Forms!Selectie!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 Sub
The correct record is shown.... so far no problem.
On this newly opened record, I created a pushbutton "Next"
Clicking on this button should show me the next record in the recordset
Alas, I get a message saying the program can not go to the desired record.
The code is:
Private Sub Knop28_Click()
DoCmd.GoToRecord acDataForm, "leerkrachten", acNext
End Sub
How to solve this problem?
Thank you so much