Hi
When a user enters in text in 2 text boxes on a form, i wish them to click a validation button. The validation button will then run a query and the query will comprise of information added in the text boxes above, the results will then appear on the same form on a label.
To do this a tek-tips master advised me to do this:
Two text boxes 1 & 3 and a label 5 on a form and:
Private Sub Command6_Click()
Dim SQL As String, db As DAO.Database, rs As DAO.Recordset
Set db = CurrentDb()
SQL = "SELECT * FROM Artist WHERE ArtistID = "
SQL = SQL & Val(Me.Text0) & " OR " & Val(Me.Text2) & ";"
' MsgBox SQL
Set rs = db.OpenRecordset(SQL)
Me.Label5.Caption = rs![artist]
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
I have done all as required above, but i then get this error message on the code area:
Compile Error:
User-Defined type not defined
and the code "As DAO.Database" is highlighted in blue.
Im not sure what to do, or can i use another piece of code?
Cheers
When a user enters in text in 2 text boxes on a form, i wish them to click a validation button. The validation button will then run a query and the query will comprise of information added in the text boxes above, the results will then appear on the same form on a label.
To do this a tek-tips master advised me to do this:
Two text boxes 1 & 3 and a label 5 on a form and:
Private Sub Command6_Click()
Dim SQL As String, db As DAO.Database, rs As DAO.Recordset
Set db = CurrentDb()
SQL = "SELECT * FROM Artist WHERE ArtistID = "
SQL = SQL & Val(Me.Text0) & " OR " & Val(Me.Text2) & ";"
' MsgBox SQL
Set rs = db.OpenRecordset(SQL)
Me.Label5.Caption = rs![artist]
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
I have done all as required above, but i then get this error message on the code area:
Compile Error:
User-Defined type not defined
and the code "As DAO.Database" is highlighted in blue.
Im not sure what to do, or can i use another piece of code?
Cheers