[ACCESS] LEGGERE/SCRIVERE DATI NELLE TABELLE TRAMITE VBA (DAO)

Click to rate this post!
[Total: 1 Average: 4]

Il seguente esempio permette di capire come prendere i valori del DB e come assegnarli in variabili.


Dim rs As Object
Dim stSql As String
Dim intOption As Integer
Dim fld As Field

Set con = Application.CurrentProject.Connection
stSql = "SELECT * FROM edit1"

Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1

While (Not (rs.EOF))
If rs.Fields("ID").Value = 2 Then
Me.MATERIA_Etichetta.BackColor = "red"
MsgBox (ok)
End If

rs.MoveNext
Wend

rs.Close
Set rs = Nothing
Set con = Nothing

CON L’UTILIZZO DEL RECORDSET

Per utilizzare il recordset occorre dal VBA instanziare l’oggetto microsoft DAO

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x