Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update label on form

Status
Not open for further replies.

Kindi

Programmer
Jan 31, 2001
54
0
0
GB
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 box above, if the query returns data, i wish this data to appear on the same form on a label. If no results are found then i wish the user to be prompted that no results have been found how can i 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


rollie@bwsys.net
 
Hi

Thanks i used the above code as suggested, but when i run the button i get this error box:

Compile Error:
User-Defined tyoe not defined

and the db "As DAO.Database" is highlighted in blue.

How can i solve this?

Thanks.
 
It seems like that Access does not know what a DAO is, or the keyword DAO.

In Access i can use the recordset keyword without the DAO, but the keyword database is not available, please help!

Thanks
 
In order to use DAO, you have to go to the design mode and press Tools and References and put a check mark in MS DAO 3.6 Library.

Tricky, Huh???

rollie@bwsys.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top