Hello everyone,
I've made a form where the user can fill in a field ID... and than by clicking on a button another form will be opened with the data of that person (with that ID that's filled in). But if the user fill in an ID that is not currently in the database, there will be also shown another form, but than with no data.. Now I want that if the ID is not known, to display a message or something (like "this ID is not known, try again") and not to open the form..
I've used the following code under the button:
Private Sub openenFormulier_Click()
On Error GoTo Err_openenFormulier_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Onderzoek"
stLinkCriteria = "[Qr_Ant_PG.ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_openenFormulier_Click:
Exit Sub
Err_openenFormulier_Click:
MsgBox Err.Description
Resume Exit_openenFormulier_Click
End Sub
Hopefully someone can help me!
Thanks,
Ankie
I've made a form where the user can fill in a field ID... and than by clicking on a button another form will be opened with the data of that person (with that ID that's filled in). But if the user fill in an ID that is not currently in the database, there will be also shown another form, but than with no data.. Now I want that if the ID is not known, to display a message or something (like "this ID is not known, try again") and not to open the form..
I've used the following code under the button:
Private Sub openenFormulier_Click()
On Error GoTo Err_openenFormulier_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Onderzoek"
stLinkCriteria = "[Qr_Ant_PG.ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_openenFormulier_Click:
Exit Sub
Err_openenFormulier_Click:
MsgBox Err.Description
Resume Exit_openenFormulier_Click
End Sub
Hopefully someone can help me!
Thanks,
Ankie
Last edited: