Afficher un MsgBox si pas de résultats
Bonjour
J'utilise deux forms pour chercher des titres de film dans une BDD Access
InterroTitre:
Code:
1 2 3 4 5 6 7 8
| Public Class InterroTitre
Private Sub Titre_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Titre.KeyDown
If (e.KeyCode = Keys.Enter) Then
e.SuppressKeyPress = True
RésultatTitre.Show()
End If
End Sub |
RésultatTitre:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Imports System
Imports System.Data
Imports System.Data.OleDb
Imports Microsoft.VisualBasic
Public Class RésultatTitre
Inherits System.Windows.Forms.Form
Private WithEvents MonRS As New ADODB.Recordset
Private Sub RésultatTitre_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TxtInterroTitre.Text = InterroTitre.Titre.Text
Me.Text = "Films contenant les mots '" & TxtInterroTitre.Text & "'"
Dim MaConn As New ADODB.Connection
MaConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
"C:\Access\DvdData.mdb"
MaConn.Open()
With MonRS
.ActiveConnection = MaConn
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
.LockType = ADODB.LockTypeEnum.adLockReadOnly
.Open("SELECT * FROM Vidéo WHERE TitreFilm like '%" & TxtInterroTitre.Text & "%'")
End With
End Sub
Private Sub MonRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal Perror As ADODB.Error, ByRef Adstatus As ADODB.EventStatusEnum, ByVal PRecordset As ADODB.Recordset) Handles MonRS.MoveComplete
Me.TextBoxNuméro.Text = MonRS.Fields(0).Value
Me.TextBoxTitre.Text = MonRS.Fields(1).Value
End Sub |
Si je tape un mot qui existe dans un titre, tout fonctionne
Par contre si aucun titre ne contient ce mot,RésultatTitre s'affiche mais vide
Or je voudrais plutôt un affichage d'un message genre "Pas de film" mais je ne sais pas où je dois coder cela
Merci d'avance