我写了下面的代号,但我在getIDKategori = rs!id_kategori
Public Function getIDKategori(ByVal nama As String) As Integer
Dim rs As New ADODB.Recordset
Set rs.ActiveConnection = CurrentProject.Connection
rs.Open "SELECT kategori.id_kategori FROM kategori WHERE nama_kategori='" & nama & "';"
getIDKategori = rs!id_kategori
rs.Close
Set rs = Nothing
End Function