Hi,
I'm really new to Access and VBA. Right now I find it quite frustrating to get error messages which I don't understand.
In a form I have a button for which I wrote some code:
Private Sub Befehl16_Click()
If IsNull(Artist) Then Exit Sub
Biography Artist
Public Sub Biography(curArtist As String)
Dim conn As ADODB.Connection
Dim rst As New ADODB.Recordset
Set conn = CurrentProject.Connection
rst.Open "SELECT Artist FROM Artist_Information WHERE Artist = " & curArtist, conn, adOpenForwardOnly, adLockReadOnly
While Not rst.EOF
curArtist = rst.Fields(0)
If curArtist = "Anna Ternheim" Then
MsgBox ("Artist Biography: Anna Ternheim was born in Sweden in 1976.")
End If
rst.MoveNext
Wend
'rst.Close
End Sub
Now I get the following message:
"Variable or Procedure expected instead of Module"
The debugger is referring to the Biography procedure. I don't understand, because Biography is in fact a procdure written in a module. So what is Access expecting here?
Thanks a lot,
Annika
I'm really new to Access and VBA. Right now I find it quite frustrating to get error messages which I don't understand.
In a form I have a button for which I wrote some code:
Private Sub Befehl16_Click()
If IsNull(Artist) Then Exit Sub
Biography Artist
Public Sub Biography(curArtist As String)
Dim conn As ADODB.Connection
Dim rst As New ADODB.Recordset
Set conn = CurrentProject.Connection
rst.Open "SELECT Artist FROM Artist_Information WHERE Artist = " & curArtist, conn, adOpenForwardOnly, adLockReadOnly
While Not rst.EOF
curArtist = rst.Fields(0)
If curArtist = "Anna Ternheim" Then
MsgBox ("Artist Biography: Anna Ternheim was born in Sweden in 1976.")
End If
rst.MoveNext
Wend
'rst.Close
End Sub
Now I get the following message:
"Variable or Procedure expected instead of Module"
The debugger is referring to the Biography procedure. I don't understand, because Biography is in fact a procdure written in a module. So what is Access expecting here?
Thanks a lot,
Annika
Last edited: