Εμφάνιση ενός μόνο μηνύματος
  #4  
Παλιά 18-04-24, 10:06
pctechdr Ο χρήστης pctechdr είναι συνδεδεμένος
Όνομα: Χρήστος
Έκδοση λογισμικού Office: Ms-Office 365
Γλώσσα λογισμικού Office: Αγγλική
 
Εγγραφή: 18-11-2012
Περιοχή: Deutschland
Μηνύματα: 205
Προεπιλογή

Βάλε μέσα σε μια λειτουργική μονάδα

Public strPeopleResult As String

Function strPeople(criteria As String) As String
Dim rs As DAO.Recordset
Dim strSql As String

strSql = "SELECT * FROM MEtavliti WHERE Peoples = '" & criteria & "'"

' Open the recordset
Set rs = CurrentDb.OpenRecordset(strSql)

' Check if there are any records
If Not rs.EOF Then
' If there are records, store the value of 'Peoples' field in the public variable
strPeopleResult = rs!Peoples
Else
' If no records match the criteria, store an empty string in the public variable
strPeopleResult = ""
End If

' Close the recordset
rs.Close
Set rs = Nothing
End Function

Και μετά για να το καλέσεις

Dim myCriteria As String
myCriteria = InputBox("Εισάγετε το όνομα:")
strPeople(myCriteria)

' Δείξε μου το αποτέλεσμα
Debug.Print strPeopleResult

Κάτι τέτοιο θέλεις?
Απάντηση με παράθεση