Check spelling of field names.
The DLookup looks correct. You are sure the room number has been entered into the table?
Add these lines to your code as a test:
Code:
Msgbox "Forms!RoomPackages!txtRoomNumber = " & Forms!RoomPackages!txtRoomNumber
Msgbox "Me.txtRoomNumber = " & Me.txtRoomNumber
Msgbox "DLookup using Forms = " & DLookup("RoomNumber", "tblRooms", "RoomNumber = " & Forms!RoomPackages!txtRoomNumber)
Msgbox "DLookup using Me. = " & DLookup("RoomNumber", "tblRooms", "RoomNumber = " & Me.txtRoomNumber)
Msgbox "DLookup fixed number= " & DLookup("RoomNumber", "tblRooms", "RoomNumber = " & 111) 'change 111 to a number that you know is in the table "tblRooms"
----------------------------------
From Post#2
Dim strSQL As String
Set rst = db.OpenRecordset("SELECT RoomNumber FROM tblRooms WHERE RoomNumber =" & Me.txtRoomNumber) ' This opens a recordset
CurrentDb.Execute strSQL 'EXECUTE is only used for Action queries. strSQL has been declared, but at this point, the value is ""
If strSQL = Me.txtRoomNumber Then ' you are comparing a Null (strSQL) to the roomnumber. strSQL still does not have a value assigned to it.
MsgBox "This number already exists."
------------------------------------
If you want, post your dB for analysis. Do a "Compact and Repair", then Zip it before attaching to a post.